Socket
Socket
Sign inDemoInstall

open-simplex-noise

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    open-simplex-noise

OpenSimplex noise for TypeScript/JavaScript


Version published
Weekly downloads
342
decreased by-0.29%
Maintainers
1
Install size
46.0 kB
Created
Weekly downloads
 

Readme

Source

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 = (x + y * width) * 4;
    const value = (openSimplex.noise2D(x, y) + 1) * 128;
    imageData.data[i] = value;
    imageData.data[i + 1] = value;
    imageData.data[i + 2] = value;
    imageData.data[i + 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

Keywords

FAQs

Last updated on 28 Oct 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc