@awayjs/stage
Version:
Stage for AwayJS
21 lines (20 loc) • 688 B
JavaScript
/**
* Implement LehmerRng for noise
* Port from Ruffle/Rust
* @see https://github.com/ruffle-rs/ruffle/blob/bb71b61c9ade6c3f185d7f0cc878423402dc4a7f/core/src/bitmap/bitmap_data.rs#L19
*/
var LehmerRng = /** @class */ (function () {
function LehmerRng(seed) {
this._x = seed;
}
/// Generate the next value in the sequence via the following formula
/// X_(k+1) = a * X_k mod m
LehmerRng.prototype.gen = function () {
return (this._x = (this._x * 16807) % 2147483647);
};
LehmerRng.prototype.genRange = function (start, end) {
return (start + (this.gen() % (end - start + 1)));
};
return LehmerRng;
}());
export { LehmerRng };