Skip to content

random

Renders must be identical across frames and machines. Use these instead of Math.random().

import { random, randomFloat, randomInt, pick } from "hyperbits/helpers";
const n = random("spark-0");
const x = randomFloat("pos-x-3", 0, 1920);
const count = randomInt("burst", 4, 12);
const glyph = pick("glyph-1", ["A", "B", "C"]);
FunctionReturns
random(seed)0–1
randomFloat(seed, min, max)float in [min, max)
randomRangealias of randomFloat
randomInt(seed, min, max)inclusive integer
pick(seed, array) / anyElementone item

seed is a number or string. The same seed always yields the same value.