mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
24 lines
424 B
JavaScript
24 lines
424 B
JavaScript
// Park-Miller-Carta Pseudo-Random Number Generator
|
|
// https://github.com/pnitsch/BitmapData.js/blob/master/js/BitmapData.js
|
|
|
|
var PRNG = function () {
|
|
|
|
this.seed = 1;
|
|
this.next = function() {
|
|
|
|
return ( this.gen() / 2147483647 );
|
|
|
|
};
|
|
this.nextRange = function( min, max ) {
|
|
|
|
return min + ( ( max - min ) * this.next() )
|
|
|
|
};
|
|
this.gen = function() {
|
|
|
|
return this.seed = ( this.seed * 16807 ) % 2147483647;
|
|
|
|
};
|
|
|
|
};
|