stb_perlin.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. // stb_perlin.h - v0.5 - perlin noise
  2. // public domain single-file C implementation by Sean Barrett
  3. //
  4. // LICENSE
  5. //
  6. // See end of file.
  7. //
  8. //
  9. // to create the implementation,
  10. // #define STB_PERLIN_IMPLEMENTATION
  11. // in *one* C/CPP file that includes this file.
  12. //
  13. //
  14. // Documentation:
  15. //
  16. // float stb_perlin_noise3( float x,
  17. // float y,
  18. // float z,
  19. // int x_wrap=0,
  20. // int y_wrap=0,
  21. // int z_wrap=0)
  22. //
  23. // This function computes a random value at the coordinate (x,y,z).
  24. // Adjacent random values are continuous but the noise fluctuates
  25. // its randomness with period 1, i.e. takes on wholly unrelated values
  26. // at integer points. Specifically, this implements Ken Perlin's
  27. // revised noise function from 2002.
  28. //
  29. // The "wrap" parameters can be used to create wraparound noise that
  30. // wraps at powers of two. The numbers MUST be powers of two. Specify
  31. // 0 to mean "don't care". (The noise always wraps every 256 due
  32. // details of the implementation, even if you ask for larger or no
  33. // wrapping.)
  34. //
  35. // float stb_perlin_noise3_seed( float x,
  36. // float y,
  37. // float z,
  38. // int x_wrap=0,
  39. // int y_wrap=0,
  40. // int z_wrap=0,
  41. // int seed)
  42. //
  43. // As above, but 'seed' selects from multiple different variations of the
  44. // noise function. The current implementation only uses the bottom 8 bits
  45. // of 'seed', but possibly in the future more bits will be used.
  46. //
  47. //
  48. // Fractal Noise:
  49. //
  50. // Three common fractal noise functions are included, which produce
  51. // a wide variety of nice effects depending on the parameters
  52. // provided. Note that each function will call stb_perlin_noise3
  53. // 'octaves' times, so this parameter will affect runtime.
  54. //
  55. // float stb_perlin_ridge_noise3(float x, float y, float z,
  56. // float lacunarity, float gain, float offset, int octaves)
  57. //
  58. // float stb_perlin_fbm_noise3(float x, float y, float z,
  59. // float lacunarity, float gain, int octaves)
  60. //
  61. // float stb_perlin_turbulence_noise3(float x, float y, float z,
  62. // float lacunarity, float gain, int octaves)
  63. //
  64. // Typical values to start playing with:
  65. // octaves = 6 -- number of "octaves" of noise3() to sum
  66. // lacunarity = ~ 2.0 -- spacing between successive octaves (use exactly 2.0 for wrapping output)
  67. // gain = 0.5 -- relative weighting applied to each successive octave
  68. // offset = 1.0? -- used to invert the ridges, may need to be larger, not sure
  69. //
  70. //
  71. // Contributors:
  72. // Jack Mott - additional noise functions
  73. // Jordan Peck - seeded noise
  74. //
  75. #ifdef __cplusplus
  76. extern "C" {
  77. #endif
  78. extern float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap);
  79. extern float stb_perlin_noise3_seed(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, int seed);
  80. extern float stb_perlin_ridge_noise3(float x, float y, float z, float lacunarity, float gain, float offset, int octaves);
  81. extern float stb_perlin_fbm_noise3(float x, float y, float z, float lacunarity, float gain, int octaves);
  82. extern float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves);
  83. extern float stb_perlin_noise3_wrap_nonpow2(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed);
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #ifdef STB_PERLIN_IMPLEMENTATION
  88. #include <math.h> // fabs()
  89. // not same permutation table as Perlin's reference to avoid copyright issues;
  90. // Perlin's table can be found at http://mrl.nyu.edu/~perlin/noise/
  91. static unsigned char stb__perlin_randtab[512] =
  92. {
  93. 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123,
  94. 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72,
  95. 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240,
  96. 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57,
  97. 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233,
  98. 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172,
  99. 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243,
  100. 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122,
  101. 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76,
  102. 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246,
  103. 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3,
  104. 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231,
  105. 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221,
  106. 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62,
  107. 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135,
  108. 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5,
  109. // and a second copy so we don't need an extra mask or static initializer
  110. 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123,
  111. 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72,
  112. 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240,
  113. 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57,
  114. 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233,
  115. 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172,
  116. 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243,
  117. 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122,
  118. 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76,
  119. 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246,
  120. 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3,
  121. 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231,
  122. 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221,
  123. 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62,
  124. 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135,
  125. 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5,
  126. };
  127. // perlin's gradient has 12 cases so some get used 1/16th of the time
  128. // and some 2/16ths. We reduce bias by changing those fractions
  129. // to 5/64ths and 6/64ths
  130. // this array is designed to match the previous implementation
  131. // of gradient hash: indices[stb__perlin_randtab[i]&63]
  132. static unsigned char stb__perlin_randtab_grad_idx[512] =
  133. {
  134. 7, 9, 5, 0, 11, 1, 6, 9, 3, 9, 11, 1, 8, 10, 4, 7,
  135. 8, 6, 1, 5, 3, 10, 9, 10, 0, 8, 4, 1, 5, 2, 7, 8,
  136. 7, 11, 9, 10, 1, 0, 4, 7, 5, 0, 11, 6, 1, 4, 2, 8,
  137. 8, 10, 4, 9, 9, 2, 5, 7, 9, 1, 7, 2, 2, 6, 11, 5,
  138. 5, 4, 6, 9, 0, 1, 1, 0, 7, 6, 9, 8, 4, 10, 3, 1,
  139. 2, 8, 8, 9, 10, 11, 5, 11, 11, 2, 6, 10, 3, 4, 2, 4,
  140. 9, 10, 3, 2, 6, 3, 6, 10, 5, 3, 4, 10, 11, 2, 9, 11,
  141. 1, 11, 10, 4, 9, 4, 11, 0, 4, 11, 4, 0, 0, 0, 7, 6,
  142. 10, 4, 1, 3, 11, 5, 3, 4, 2, 9, 1, 3, 0, 1, 8, 0,
  143. 6, 7, 8, 7, 0, 4, 6, 10, 8, 2, 3, 11, 11, 8, 0, 2,
  144. 4, 8, 3, 0, 0, 10, 6, 1, 2, 2, 4, 5, 6, 0, 1, 3,
  145. 11, 9, 5, 5, 9, 6, 9, 8, 3, 8, 1, 8, 9, 6, 9, 11,
  146. 10, 7, 5, 6, 5, 9, 1, 3, 7, 0, 2, 10, 11, 2, 6, 1,
  147. 3, 11, 7, 7, 2, 1, 7, 3, 0, 8, 1, 1, 5, 0, 6, 10,
  148. 11, 11, 0, 2, 7, 0, 10, 8, 3, 5, 7, 1, 11, 1, 0, 7,
  149. 9, 0, 11, 5, 10, 3, 2, 3, 5, 9, 7, 9, 8, 4, 6, 5,
  150. // and a second copy so we don't need an extra mask or static initializer
  151. 7, 9, 5, 0, 11, 1, 6, 9, 3, 9, 11, 1, 8, 10, 4, 7,
  152. 8, 6, 1, 5, 3, 10, 9, 10, 0, 8, 4, 1, 5, 2, 7, 8,
  153. 7, 11, 9, 10, 1, 0, 4, 7, 5, 0, 11, 6, 1, 4, 2, 8,
  154. 8, 10, 4, 9, 9, 2, 5, 7, 9, 1, 7, 2, 2, 6, 11, 5,
  155. 5, 4, 6, 9, 0, 1, 1, 0, 7, 6, 9, 8, 4, 10, 3, 1,
  156. 2, 8, 8, 9, 10, 11, 5, 11, 11, 2, 6, 10, 3, 4, 2, 4,
  157. 9, 10, 3, 2, 6, 3, 6, 10, 5, 3, 4, 10, 11, 2, 9, 11,
  158. 1, 11, 10, 4, 9, 4, 11, 0, 4, 11, 4, 0, 0, 0, 7, 6,
  159. 10, 4, 1, 3, 11, 5, 3, 4, 2, 9, 1, 3, 0, 1, 8, 0,
  160. 6, 7, 8, 7, 0, 4, 6, 10, 8, 2, 3, 11, 11, 8, 0, 2,
  161. 4, 8, 3, 0, 0, 10, 6, 1, 2, 2, 4, 5, 6, 0, 1, 3,
  162. 11, 9, 5, 5, 9, 6, 9, 8, 3, 8, 1, 8, 9, 6, 9, 11,
  163. 10, 7, 5, 6, 5, 9, 1, 3, 7, 0, 2, 10, 11, 2, 6, 1,
  164. 3, 11, 7, 7, 2, 1, 7, 3, 0, 8, 1, 1, 5, 0, 6, 10,
  165. 11, 11, 0, 2, 7, 0, 10, 8, 3, 5, 7, 1, 11, 1, 0, 7,
  166. 9, 0, 11, 5, 10, 3, 2, 3, 5, 9, 7, 9, 8, 4, 6, 5,
  167. };
  168. static float stb__perlin_lerp(float a, float b, float t)
  169. {
  170. return a + (b-a) * t;
  171. }
  172. static int stb__perlin_fastfloor(float a)
  173. {
  174. int ai = (int) a;
  175. return (a < ai) ? ai-1 : ai;
  176. }
  177. // different grad function from Perlin's, but easy to modify to match reference
  178. static float stb__perlin_grad(int grad_idx, float x, float y, float z)
  179. {
  180. static float basis[12][4] =
  181. {
  182. { 1, 1, 0 },
  183. { -1, 1, 0 },
  184. { 1,-1, 0 },
  185. { -1,-1, 0 },
  186. { 1, 0, 1 },
  187. { -1, 0, 1 },
  188. { 1, 0,-1 },
  189. { -1, 0,-1 },
  190. { 0, 1, 1 },
  191. { 0,-1, 1 },
  192. { 0, 1,-1 },
  193. { 0,-1,-1 },
  194. };
  195. float *grad = basis[grad_idx];
  196. return grad[0]*x + grad[1]*y + grad[2]*z;
  197. }
  198. float stb_perlin_noise3_internal(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed)
  199. {
  200. float u,v,w;
  201. float n000,n001,n010,n011,n100,n101,n110,n111;
  202. float n00,n01,n10,n11;
  203. float n0,n1;
  204. unsigned int x_mask = (x_wrap-1) & 255;
  205. unsigned int y_mask = (y_wrap-1) & 255;
  206. unsigned int z_mask = (z_wrap-1) & 255;
  207. int px = stb__perlin_fastfloor(x);
  208. int py = stb__perlin_fastfloor(y);
  209. int pz = stb__perlin_fastfloor(z);
  210. int x0 = px & x_mask, x1 = (px+1) & x_mask;
  211. int y0 = py & y_mask, y1 = (py+1) & y_mask;
  212. int z0 = pz & z_mask, z1 = (pz+1) & z_mask;
  213. int r0,r1, r00,r01,r10,r11;
  214. #define stb__perlin_ease(a) (((a*6-15)*a + 10) * a * a * a)
  215. x -= px; u = stb__perlin_ease(x);
  216. y -= py; v = stb__perlin_ease(y);
  217. z -= pz; w = stb__perlin_ease(z);
  218. r0 = stb__perlin_randtab[x0+seed];
  219. r1 = stb__perlin_randtab[x1+seed];
  220. r00 = stb__perlin_randtab[r0+y0];
  221. r01 = stb__perlin_randtab[r0+y1];
  222. r10 = stb__perlin_randtab[r1+y0];
  223. r11 = stb__perlin_randtab[r1+y1];
  224. n000 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z0], x , y , z );
  225. n001 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z1], x , y , z-1 );
  226. n010 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z0], x , y-1, z );
  227. n011 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z1], x , y-1, z-1 );
  228. n100 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z0], x-1, y , z );
  229. n101 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z1], x-1, y , z-1 );
  230. n110 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z0], x-1, y-1, z );
  231. n111 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z1], x-1, y-1, z-1 );
  232. n00 = stb__perlin_lerp(n000,n001,w);
  233. n01 = stb__perlin_lerp(n010,n011,w);
  234. n10 = stb__perlin_lerp(n100,n101,w);
  235. n11 = stb__perlin_lerp(n110,n111,w);
  236. n0 = stb__perlin_lerp(n00,n01,v);
  237. n1 = stb__perlin_lerp(n10,n11,v);
  238. return stb__perlin_lerp(n0,n1,u);
  239. }
  240. float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap)
  241. {
  242. return stb_perlin_noise3_internal(x,y,z,x_wrap,y_wrap,z_wrap,0);
  243. }
  244. float stb_perlin_noise3_seed(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, int seed)
  245. {
  246. return stb_perlin_noise3_internal(x,y,z,x_wrap,y_wrap,z_wrap, (unsigned char) seed);
  247. }
  248. float stb_perlin_ridge_noise3(float x, float y, float z, float lacunarity, float gain, float offset, int octaves)
  249. {
  250. int i;
  251. float frequency = 1.0f;
  252. float prev = 1.0f;
  253. float amplitude = 0.5f;
  254. float sum = 0.0f;
  255. for (i = 0; i < octaves; i++) {
  256. float r = stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i);
  257. r = offset - (float) fabs(r);
  258. r = r*r;
  259. sum += r*amplitude*prev;
  260. prev = r;
  261. frequency *= lacunarity;
  262. amplitude *= gain;
  263. }
  264. return sum;
  265. }
  266. float stb_perlin_fbm_noise3(float x, float y, float z, float lacunarity, float gain, int octaves)
  267. {
  268. int i;
  269. float frequency = 1.0f;
  270. float amplitude = 1.0f;
  271. float sum = 0.0f;
  272. for (i = 0; i < octaves; i++) {
  273. sum += stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i)*amplitude;
  274. frequency *= lacunarity;
  275. amplitude *= gain;
  276. }
  277. return sum;
  278. }
  279. float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves)
  280. {
  281. int i;
  282. float frequency = 1.0f;
  283. float amplitude = 1.0f;
  284. float sum = 0.0f;
  285. for (i = 0; i < octaves; i++) {
  286. float r = stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i)*amplitude;
  287. sum += (float) fabs(r);
  288. frequency *= lacunarity;
  289. amplitude *= gain;
  290. }
  291. return sum;
  292. }
  293. float stb_perlin_noise3_wrap_nonpow2(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed)
  294. {
  295. float u,v,w;
  296. float n000,n001,n010,n011,n100,n101,n110,n111;
  297. float n00,n01,n10,n11;
  298. float n0,n1;
  299. int px = stb__perlin_fastfloor(x);
  300. int py = stb__perlin_fastfloor(y);
  301. int pz = stb__perlin_fastfloor(z);
  302. int x_wrap2 = (x_wrap ? x_wrap : 256);
  303. int y_wrap2 = (y_wrap ? y_wrap : 256);
  304. int z_wrap2 = (z_wrap ? z_wrap : 256);
  305. int x0 = px % x_wrap2, x1;
  306. int y0 = py % y_wrap2, y1;
  307. int z0 = pz % z_wrap2, z1;
  308. int r0,r1, r00,r01,r10,r11;
  309. if (x0 < 0) x0 += x_wrap2;
  310. if (y0 < 0) y0 += y_wrap2;
  311. if (z0 < 0) z0 += z_wrap2;
  312. x1 = (x0+1) % x_wrap2;
  313. y1 = (y0+1) % y_wrap2;
  314. z1 = (z0+1) % z_wrap2;
  315. #define stb__perlin_ease(a) (((a*6-15)*a + 10) * a * a * a)
  316. x -= px; u = stb__perlin_ease(x);
  317. y -= py; v = stb__perlin_ease(y);
  318. z -= pz; w = stb__perlin_ease(z);
  319. r0 = stb__perlin_randtab[x0];
  320. r0 = stb__perlin_randtab[r0+seed];
  321. r1 = stb__perlin_randtab[x1];
  322. r1 = stb__perlin_randtab[r1+seed];
  323. r00 = stb__perlin_randtab[r0+y0];
  324. r01 = stb__perlin_randtab[r0+y1];
  325. r10 = stb__perlin_randtab[r1+y0];
  326. r11 = stb__perlin_randtab[r1+y1];
  327. n000 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z0], x , y , z );
  328. n001 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z1], x , y , z-1 );
  329. n010 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z0], x , y-1, z );
  330. n011 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z1], x , y-1, z-1 );
  331. n100 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z0], x-1, y , z );
  332. n101 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z1], x-1, y , z-1 );
  333. n110 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z0], x-1, y-1, z );
  334. n111 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z1], x-1, y-1, z-1 );
  335. n00 = stb__perlin_lerp(n000,n001,w);
  336. n01 = stb__perlin_lerp(n010,n011,w);
  337. n10 = stb__perlin_lerp(n100,n101,w);
  338. n11 = stb__perlin_lerp(n110,n111,w);
  339. n0 = stb__perlin_lerp(n00,n01,v);
  340. n1 = stb__perlin_lerp(n10,n11,v);
  341. return stb__perlin_lerp(n0,n1,u);
  342. }
  343. #endif // STB_PERLIN_IMPLEMENTATION
  344. /*
  345. ------------------------------------------------------------------------------
  346. This software is available under 2 licenses -- choose whichever you prefer.
  347. ------------------------------------------------------------------------------
  348. ALTERNATIVE A - MIT License
  349. Copyright (c) 2017 Sean Barrett
  350. Permission is hereby granted, free of charge, to any person obtaining a copy of
  351. this software and associated documentation files (the "Software"), to deal in
  352. the Software without restriction, including without limitation the rights to
  353. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  354. of the Software, and to permit persons to whom the Software is furnished to do
  355. so, subject to the following conditions:
  356. The above copyright notice and this permission notice shall be included in all
  357. copies or substantial portions of the Software.
  358. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  359. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  360. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  361. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  362. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  363. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  364. SOFTWARE.
  365. ------------------------------------------------------------------------------
  366. ALTERNATIVE B - Public Domain (www.unlicense.org)
  367. This is free and unencumbered software released into the public domain.
  368. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
  369. software, either in source code form or as a compiled binary, for any purpose,
  370. commercial or non-commercial, and by any means.
  371. In jurisdictions that recognize copyright laws, the author or authors of this
  372. software dedicate any and all copyright interest in the software to the public
  373. domain. We make this dedication for the benefit of the public at large and to
  374. the detriment of our heirs and successors. We intend this dedication to be an
  375. overt act of relinquishment in perpetuity of all present and future rights to
  376. this software under copyright law.
  377. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  378. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  379. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  380. AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  381. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  382. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  383. ------------------------------------------------------------------------------
  384. */