artworld.js/artworld/random.js
2024-07-06 17:15:25 -05:00

20 lines
315 B
JavaScript

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