MCPcopy
hub / github.com/jwagner/simplex-noise.js / buildPermutationTable

Function buildPermutationTable

simplex-noise.ts:484–500  ·  view source on GitHub ↗
(random: RandomFn)

Source from the content-addressed store, hash-verified

482 * @private
483 */
484export function buildPermutationTable(random: RandomFn): Uint8Array {
485 const tableSize = 512;
486 const p = new Uint8Array(tableSize);
487 for (let i = 0; i < tableSize / 2; i++) {
488 p[i] = i;
489 }
490 for (let i = 0; i < tableSize / 2 - 1; i++) {
491 const r = i + ~~(random() * (256 - i));
492 const aux = p[i];
493 p[i] = p[r];
494 p[r] = aux;
495 }
496 for (let i = 256; i < tableSize; i++) {
497 p[i] = p[i - 256];
498 }
499 return p;
500}

Callers 4

createNoise2DFunction · 0.85
createNoise3DFunction · 0.85
createNoise4DFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected