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.
A demo can be found at codepen Simplex Noise 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)