Skip to content

simplex

Since v8.0.74

Simplex

A noise generator based on the Simplex noise algorithm.

Syntax
new Simplex(seed)
Parameters

seed seed number.

Return value

A new Simplex generator object.

eval()

Returns a random noise value. Repeated calls with the same args inputs will have the same output.

Syntax
eval(arg1)
eval(arg1, arg2)
eval(arg1, arg2, arg3)
eval(arg1, arg2, arg3, arg4)
Parameters

args Number A variable-length list of numbers, representing dimensions. The function accepts a minimum of one argument (1-dimensional) and a maximum of four arguments (4-dimensional).

Return value

Number random noise value

Usage example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
const g = require("mathx/simplex")
simplex = new g.Simplex(123);
for(i=0; i < 5; i++) {
    noise = simplex.eval(i, i * 0.6).toFixed(3);
    console.log(i, (i*0.6).toFixed(1), "=>", noise);
}

// 0 0.0 => 0.000
// 1 0.6 => 0.349
// 2 1.2 => 0.319
// 3 1.8 => 0.038
// 4 2.4 => -0.364
Last updated on