-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
48 lines (40 loc) · 1.12 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var seedRandom = require('seed-random');
var createRandomRange = require('./lib/random-range');
const generatePalette = require('./lib/generatePalette');
module.exports = function (seed) {
if (typeof seed === 'undefined') {
seed = String(Math.floor(Math.random() * 1000000));
}
var randomFunc = seedRandom(seed);
var random = createRandomRange(randomFunc);
return {
// rendering options
random: randomFunc,
seedName: seed,
pointilism: random(0.01, 0.1),
noiseScalar: [ random(0.000001, 0.000001), random(0.0002, 0.004) ],
globalAlpha: 0.5,
maxRadius: random(15, 25),
lineStyle: random(1) > 0.5 ? 'round' : 'square',
interval: random(0.001, 0.01),
steps: Math.floor(random(400, 800)),
// browser/node options
pixelRatio: 1,
width: 1280 * 2,
height: 720 * 2,
palette: generatePalette(),
};
function arrayShuffle (arr) {
var rand;
var tmp;
var len = arr.length;
var ret = arr.slice();
while (len) {
rand = Math.floor(random(1) * len--);
tmp = ret[len];
ret[len] = ret[rand];
ret[rand] = tmp;
}
return ret;
}
};