UNPKG

rough-native

Version:

Create graphics using HTML Canvas or SVG with a hand-drawn, sketchy, appearance. Features comprehensive React hooks, memory management, and React 18 concurrent rendering support.

18 lines (17 loc) 475 B
import { CONFIG } from './config.js'; export function randomSeed() { return Math.floor(Math.random() * CONFIG.RANDOM.SEED_UPPER_BOUND); } export class Random { constructor(seed) { this.seed = seed; } next() { if (this.seed) { return (CONFIG.RANDOM.LCG_MASK & (this.seed = Math.imul(CONFIG.RANDOM.LCG_MULTIPLIER, this.seed))) / CONFIG.RANDOM.LCG_DIVISOR; } else { return Math.random(); } } }