artworld.js/artworld/random.js

20 lines
315 B
JavaScript
Raw Normal View History

2024-07-06 20:21:35 +00:00
export class Random {
static chance(odds) {
return Math.random() < odds;
}
2024-07-06 21:28:51 +00:00
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;
}
2024-07-06 20:21:35 +00:00
}