Fractal Noise
Fractal noise library
Install
npm install fractal-noise
Examples
generateCylinder(width, height, { frequency: 0.04, octaves: 2 })
generateCylinder(width, height, { frequency: 0.06, octaves: 8 })
generateLine(width)
generateLine(height, { frequency: 0.1 })
generateRectangle(width, height)
generateRectangle(width, height, { frequency: 0.04, octaves: 8 })
API
Options
The options
object for each generate
function contains the following properties:
amplitude?: number
– Defaults to 1.0
frequency?: number
– Defaults to 1.0
octaves?: number
– Defaults to 1
persistence?: number
– Defaults to 0.5
generateCuboid (width: number, height: number, depth: number, options: Options = {}): Uint8Array[][]
Generates a three-dimensional noise field for a rectangular cuboid.
generateCylinder (circumference: number, height: number, options: Options = {}): Uint8Array[]
Generates a two-dimensional noise field formed around a three-dimensional cylinder, such that it is continuous across the x-boundaries.
generateLine (length: number, options: Options = {}): number[]
Generates a one-dimensional noise field.
generateRectangle (width: number, height: number, options: Options = {}): Uint8Array[]
Generates a two-dimensional noise field isolated to width
and height
(non-continuous noise).
generateSphere (circumference: number, options: Options = {}): Uint8Array[]
Generates a two-dimensional noise field formed on the surface of a three-dimensional sphere.