It requires typed arrays, if you want to use it in browsers without support you will need to use a polyfill like typedarray.js.
// initializing a simplex instance// do this only once it's relatively expensivevar simplex =value2d = simplexnoise2Dx yvalue3d = simplexnoise3Dx y zvalue4d = simplexnoise4Dx y z w;
You can also pass an alternative random function to the constructor that is used to build the permutation table:
var simplex = Mathrandomvalue2d = simplexnoise2Dx y;
This can be used with a PRNG like alea to initialize the noise function with a seed:
var random = seedsimplex = randomvalue2d = simplexnoise2Dx y;
The ALEA PRNG can be found on npm.
Node.js is also supported, you can install the package using npm.
var SimplexNoise = require'simplex-noise'simplex = Mathrandomvalue2d = simplexnoise2Dx y;
For development you can open
perf/index.html and watch the console or run
node perf/benchmark.js in a shell.
There is also a rake task for comparing your current changes can also run
The command works using git stash.
There are some simple buster.js tests for this library to run them first install buster.js and jshint:
npm install buster# if you haven't done so alreadynpm install -g jshintmake tests
Copyright (c) 2015 Jonas Wanger, licensed under the MIT License (enclosed)