artworld.js/artworld/random.js
2024-07-06 16:28:51 -05:00

21 lines
349 B
JavaScript

export class Random {
static chance(odds) {
return Math.random() < odds;
}
static under(num) {
let n = Math.random() * num;
console.log("under", num, n);
return n;
}
static between(lo, hi) {
let n = Math.random() * (hi - lo) + lo;
return n;
}
static radians() {
return Math.random() * Math.PI * 2;
}
}