Negatively Proportional Model
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

open-simplex-noise

1.5.0 • Public • Published

OpenSimplex Noise

build npm

TypeScript/JavaScript implementation of OpenSimplex noise

Install

npm install open-simplex-noise

Example

import OpenSimplexNoise from 'open-simplex-noise';
 
const [width, height] = [888, 222];
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
const imageData = ctx.createImageData(width, height);
const openSimplex = new OpenSimplexNoise(Date.now());
 
for (let x = 0; x < width; x++) {
  for (let y = 0; y < height; y++) {
    const i = (+ y * width) * 4;
    const value = (openSimplex.noise2D(x, y) + 1) * 128;
    imageData.data[i] = value;
    imageData.data[+ 1] = value;
    imageData.data[+ 2] = value;
    imageData.data[+ 3] = 255;
  }
}
ctx.putImageData(imageData, 0, 0);

Example output

API

class OpenSimplexNoise

constructor (seed: number)

array2D (width: number, height: number) => number[][]

array3D (width: number, height: number, depth: number) => number[][][]

array4D (width: number, height: number, depth: number, wLength: number) => number[][][][]

noise2D (x: number, y: number) => number

noise3D (x: number, y: number, z: number) => number

noise4D (x: number, y: number, z: number, w: number) => number

install

npm i open-simplex-noise

Downloadsweekly downloads

25

version

1.5.0

license

Unlicense

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar