The integer hashes that many upstream pieces share, word for word.
Each returns upstream's value: a float in [0, 1) or, for distro/3, the
unsigned integer. Arguments may be integers or floats (truncated, as JS's
Math.imul and | 0 truncate). They run in unsigned arithmetic with the
multiply inlined, since ^, >>>, + and Math.imul agree modulo 2^32
whatever the signs; that makes them several times faster than the same
steps through Ascii.Int32, which matters for scenes that hash tens of
thousands of times a frame.
A piece whose hash is not one of these writes its own with
Ascii.Int32.
Summary
Functions
The distros' scan noise, as an unsigned integer
A murmur-style hash of two (aurora, doom-fire, lightning, saptarishi, aquarium, campfire, cherry-blossom)
The same of three (sunrise, tv-static, wind)
The scenes' hash (night-coast, alpine-dawn and every other scene, and dissolve)
One round of the murmur-style hash (lighthouse, train, windmill, fractal-tree, landscape)
Functions
@spec distro(x :: number(), y :: number(), k :: number()) :: non_neg_integer()
The distros' scan noise, as an unsigned integer:
let h = Math.imul(x, 73856093) ^ Math.imul(y, 19349663) ^ Math.imul(k, 83492791);
h = Math.imul(h ^ (h >>> 13), 1274126177);
return (h ^ (h >>> 16)) >>> 0;
A murmur-style hash of two (aurora, doom-fire, lightning, saptarishi, aquarium, campfire, cherry-blossom):
let h = Math.imul(x, 0x27d4eb2d) ^ Math.imul(y, 0x165667b1);
h = Math.imul(h ^ (h >>> 15), 0x85ebca6b);
h = Math.imul(h ^ (h >>> 13), 0xc2b2ae35);
return ((h ^ (h >>> 16)) >>> 0) / 4294967296;
The same of three (sunrise, tv-static, wind):
let h = Math.imul(a, 0x27d4eb2d) ^ Math.imul(b, 0x165667b1) ^ Math.imul(c, 0x2545f491);then as murmur/2.
The scenes' hash (night-coast, alpine-dawn and every other scene, and dissolve):
let h = Math.imul(x | 0, 374761393) + Math.imul(y | 0, 668265263);
h = Math.imul(h ^ (h >>> 13), 1274126177);
return ((h ^ (h >>> 16)) >>> 0) / 4294967296;
One round of the murmur-style hash (lighthouse, train, windmill, fractal-tree, landscape):
let h = Math.imul(x, 0x27d4eb2d) ^ Math.imul(y, 0x165667b1);
h = Math.imul(h ^ (h >>> 15), 0x85ebca6b);
return ((h ^ (h >>> 13)) >>> 0) / 4294967296;