File indexing completed on 2024-06-23 04:27:09
0001 #ifndef OPEN_SIMPLEX_NOISE_H__ 0002 #define OPEN_SIMPLEX_NOISE_H__ 0003 0004 /* 0005 * OpenSimplex (Simplectic) Noise in C. 0006 * Ported to C from Kurt Spencer's java implementation by Stephen M. Cameron 0007 * 0008 * v1.1 (October 6, 2014) 0009 * - Ported to C 0010 * 0011 * v1.1 (October 5, 2014) 0012 * - Added 2D and 4D implementations. 0013 * - Proper gradient sets for all dimensions, from a 0014 * dimensionally-generalizable scheme with an actual 0015 * rhyme and reason behind it. 0016 * - Removed default permutation array in favor of 0017 * default seed. 0018 * - Changed seed-based constructor to be independent 0019 * of any particular randomization library, so results 0020 * will be the same when ported to other languages. 0021 */ 0022 0023 #if (defined (__STDC_VERSION__) || defined (__GNUC_STDC_INLINE__)) 0024 #if ((__GNUC_STDC_INLINE__) || (__STDC_VERSION__ >= 199901L)) 0025 #include <stdint.h> 0026 #define INLINE inline 0027 #endif 0028 #elif (defined (_MSC_VER) || defined (__GNUC_GNU_INLINE__)) 0029 #include <stdint.h> 0030 #define INLINE __inline 0031 #else 0032 /* ANSI C doesn't have inline or stdint.h. */ 0033 #define INLINE 0034 #endif 0035 0036 #ifdef __cplusplus 0037 extern "C" { 0038 #endif 0039 0040 struct osn_context; 0041 0042 int open_simplex_noise(int64_t seed, struct osn_context **ctx); 0043 void open_simplex_noise_free(struct osn_context *ctx); 0044 int open_simplex_noise_init_perm(struct osn_context *ctx, int16_t p[], int nelements); 0045 double open_simplex_noise2(struct osn_context *ctx, double x, double y); 0046 double open_simplex_noise3(struct osn_context *ctx, double x, double y, double z); 0047 double open_simplex_noise4(struct osn_context *ctx, double x, double y, double z, double w); 0048 0049 #ifdef __cplusplus 0050 } 0051 #endif 0052 0053 #endif