-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
47 lines (23 loc) · 807 Bytes
/
script.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
document.body.onload = generate;
function generate() {
let root = document.documentElement;
var colors = [
'#ff0073', '#00eaff', '#ffd240'
],
total = 20,
space = parseInt(window.innerWidth / total);
for (let i=0; i<total; i++) {
let dot = document.createElement('div');
let ind = parseInt(random(colors.length,0));
dot.className = 'dots';
dot.style.background = colors[ind];
dot.style.boxShadow = '0 0 1vw 0.2vw ' + colors[ind];
dot.style.left = space * i + 'px';
dot.style.animationDelay = random(5, 0.2) + 's';
dot.style.animationDuration = random(10, 3) + 's';
document.body.appendChild(dot);
}
}
function random(max, min) {
return Math.random() * (max - min + 1) + min;
}