/png5

A multidimensional noise engine for every situation

Primary LanguageJavaScriptMIT LicenseMIT

GitHub tag (latest by date) PRs welcome GitHub

A multidimensional noise engine for every situation

( And one day for every noise type ) png5 stands for perlin noise generator but it does not provide only perlin noise !

  • Undetermined random
  • Determined random
  • White noise
  • Pink noise
  • Simplex noise
  • Perlin noise
  • Brownian noise
  • Cellular noise

Features

  • Light weight
  • Easy to use

Installation

npm install png5 --save

Usage

  • Using the generator with Node :
// Import
const NoiseGenerator = require('png5')

// Initialize and config at the same time
const myNoiseMachine = new NoiseGenerator({
    lod: 2,
    falloff: 0.25
    seed: 'seed'
})

// Initialize and config later
const myNoiseMachine = new NoiseGenerator()
myNoiseMachine.setNoiseDetail(2, 0.25)
myNoiseMachine.setSeed('seed')

// By default the noise generator noise detail lod is set to 4 and falloff to  0.5
// If no seed is provided, the generator will use a random string

// Get a 1D noise at index x
const noise1D = myNoiseMachine.getPerlinNoise(x)

// Get a 2D noise at x,y coordinates
const noise2D = myNoiseMachine.getPerlinNoise(x,y)

// Get a 3D noise at x,y,z coordinates
const noise3D = myNoiseMachine.getPerlinNoise(x,y,z)

Methods of the noise generator class

random([x])
x / Number: x-coordinate in noise space (Optional)
If no parameter is passed to the function it return an undetermined random number
getWhiteNoise(x, [y], [z])
x / Number: x-coordinate in noise space
y / Number: y-coordinate in noise space (Optional)
z / Number: z-coordinate in noise space (Optional)
getPerlinNoise(x, [y], [z])
x / Number: x-coordinate in noise space
y / Number: y-coordinate in noise space (Optional)
z / Number: z-coordinate in noise space (Optional)
setNoiseDetail(lod, falloff)
lod / Number: number of octaves to be used by the noise
falloff / Number: falloff factor for each octave
setNoiseSeed(seed)
seed / Number or String: the seed value
String inputs are converted to binary to serve as a Number input for the algorythms