Skip to content
Javascript implementation of OpenSimplex Noise
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitattributes 🎉 Added .gitattributes Nov 4, 2017
LICENSE First release Nov 4, 2017
README.md
simplexNoise.js First release Nov 4, 2017

README.md

SimplexNoiseJS

A JavaScript rewrite of typescript Open-Simplex-Noise an implementation of OpenSimplex noise

The rewrite provides a 15-20% performance improvement on the typescript implementation, file size reduction from 24.28K to 14.66K, and a reduced runtime memory footprint.

Demo

A demo can be found at codepen Simplex Noise Example

Example

const seed = Date.now();
const [width, height] = [888, 222];
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
const imageData = ctx.createImageData(width, height);
const openSimplex = openSimplexNoise(seed);
const zoom = 8;
var x, y, index = 0;
for (y = 0; y < height; y++) {
  for (x = 0; x < width; x++) {
    const value = (openSimplex.noise2D(x / zoom, y / zoom) + 1) * 128;
    imageData.data[index++] = value;
    imageData.data[index++] = value;
    imageData.data[index++] = value;
    imageData.data[index++] = 255;
  }
}
ctx.putImageData(imageData, 0, 0)

API

function openSimplexNoise

creation openSimplexNoise(seed) => API

API.noise2D (x, y) => -1 < number < 1

API.noise3D (x, y, z) => -1 < number < 1

API.noise4D (x, y, z, w) => -1 < number < 1

You can’t perform that action at this time.