Test
advanced noise generation for the browser and node.js
:warning: Work in progress. Expect breaking changes!
add uber-noise to your project and import/require it
npm i uber-noise
const UberNoise = require("uber-noise");
// OR
import UberNoise from "uber-noise";
add script tag to your html and use the global class variable UberNoise
<script src="https://cdn.jsdelivr.net/npm/uber-noise@0.1.8"></script>
const noise = new UberNoise();
const value = noise.get(x, y);
const noise = new UberNoise();
// get noise value at x,y
const value = noise.get(x, y);
// get noise value at x,y,z
const value = noise.get(x, y, z);
// get noise value at x,y,z,w
const value = noise.get(x, y, z, w);
// simple fbm noise
const noise = new UberNoise({
scale: 0.01,
octaves: 4,
gain: 0.5,
lacunarity: 2.0,
});
const noise = new UberNoise({
scale: { min: 0.01, max: 0.1, scale: 0.01 }, // this will set the scale to a noise instance returning values between 0.01 and 0.1
});
<script src="https://cdn.jsdelivr.net/npm/uber-noise@0.1.8"></script>
// creating noise in setup()
noise = new UberNoise({ scale: 0.005 });
// using noise in draw()
for (let x = 0; x < width; x += stepSize) {
let v = noise.get(x + counter);
// ... use v to draw something
}