Simple Perlin noise derived from p5.js
# Using npm
npm install @chriscourses/perlin-noise
# Using Yarn
yarn add @chriscourses/perlin-noise
Return a Perlin noise value 0-1:
import { noise } from '@chriscourses/perlin-noise'
const x = noise(10) // returns value 0-1
You can also call noise
in sequence to access all pre-generated noise values:
for (let i = 0; i < 100; i += 0.01;) {
const x = noise(i) // returns value 0-1, but different and related to the previous return value on each loop cycle
}
Returns a Perlin noise generated value 0 - 1
Parameter | Type | Description |
---|---|---|
x | number | x value for one dimensional noise |
y (optional) | number | y value for two dimensional noise |
z (optional) | number | z value for three dimensional noise |