You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

open_simplex_noise.h 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef OPEN_SIMPLEX_NOISE_H__
  2. #define OPEN_SIMPLEX_NOISE_H__
  3. /*
  4. * OpenSimplex (Simplectic) Noise in C.
  5. * Ported to C from Kurt Spencer's java implementation by Stephen M. Cameron
  6. *
  7. * v1.1 (October 6, 2014)
  8. * - Ported to C
  9. *
  10. * v1.1 (October 5, 2014)
  11. * - Added 2D and 4D implementations.
  12. * - Proper gradient sets for all dimensions, from a
  13. * dimensionally-generalizable scheme with an actual
  14. * rhyme and reason behind it.
  15. * - Removed default permutation array in favor of
  16. * default seed.
  17. * - Changed seed-based constructor to be independent
  18. * of any particular randomization library, so results
  19. * will be the same when ported to other languages.
  20. */
  21. #if ((__GNUC_STDC_INLINE__) || (__STDC_VERSION__ >= 199901L))
  22. #include <stdint.h>
  23. #define INLINE inline
  24. #elif (defined (_MSC_VER) || defined (__GNUC_GNU_INLINE__))
  25. #include <stdint.h>
  26. #define INLINE __inline
  27. #else
  28. /* ANSI C doesn't have inline or stdint.h. */
  29. #define INLINE
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. struct osn_context;
  35. int open_simplex_noise(int64_t seed, struct osn_context **ctx);
  36. void open_simplex_noise_free(struct osn_context *ctx);
  37. int open_simplex_noise_init_perm(struct osn_context *ctx, int16_t p[], int nelements);
  38. double open_simplex_noise2(struct osn_context *ctx, double x, double y);
  39. double open_simplex_noise3(struct osn_context *ctx, double x, double y, double z);
  40. double open_simplex_noise4(struct osn_context *ctx, double x, double y, double z, double w);
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif