UNPKG

782 BJavaScriptView Raw
1(function() {
2
3const Alea = require('alea');
4const FastSimplexNoise = require('fast-simplex-noise');
5const FastUniformNoise = require('fast-uniform-noise');
6
7function Indev(opts) {
8 opts = opts || {};
9 const seed = opts.seed;
10
11 this._random = seed !== undefined ? new Alea(seed) : Math.random;
12}
13Indev.prototype = {
14 simplex: function(opts) {
15 opts = opts || {};
16 opts.min = opts.min || 0;
17 opts.max = opts.max || 1;
18 opts.random = this._random;
19
20 return new FastSimplexNoise(opts);
21 },
22 uniform: function(opts) {
23 opts = opts || {};
24 opts.min = opts.min || 0;
25 opts.max = opts.max || 1;
26 opts.random = this._random;
27
28 return new FastUniformNoise(opts);
29 },
30};
31
32function indev(opts) {
33 return new Indev(opts);
34}
35
36module.exports = indev;
37
38})();