-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpowerball.js
96 lines (84 loc) · 4.23 KB
/
powerball.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
(() => {
let circle = [];
let svg = [];
const buildSvg = () => {
const svg = document.createElementNS(
"http://www.w3.org/2000/svg",
"svg"
);
const container = document.getElementById("container");
container.appendChild(svg);
return svg;
};
const buildCircle = () => {
const circle = document.createElementNS(
"http://www.w3.org/2000/svg",
"circle"
);
circle.setAttribute("width", "500");
circle.setAttribute("height", "500");
circle.setAttribute("cx", "50%");
circle.setAttribute("cy", "50%");
circle.setAttribute("r", "50");
svg.appendChild(circle);
return circle;
};
const kickOff = (circle) => {
let rando;
setInterval(() => {
let pix = vhTOpx(40);
rando = Math.round(Math.random(100) * (pix / 2));
circle.setAttribute("r", rando);
circle.setAttribute("fill", "hsla(" + rando + ", 50%, 50%, 0.35)");
}, 440);
};
const relocate = ({ clientX, clientY, preventDefault, target }) => {
const container = document.getElementById("container");
container.style.transform = `translate(${clientX - 250}px, ${
clientY - 500
}px)`;
};
const listenForPokes = () => {
document.addEventListener("click", relocate, false);
};
const activate = (idx) => {
svg = buildSvg();
svg.setAttribute("width", "100vh");
svg.setAttribute("height", "100vh");
for (let i = 0; i < 15; i++) {
circle[i] = buildCircle(idx);
setTimeout(() => {
kickOff(circle[i]);
}, 220);
}
listenForPokes();
showMsg();
};
activate();
function vhTOpx(value) {
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName("body")[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight || g.clientHeight;
var result = (y * value) / 100;
return result;
}
function showMsg() {
const msg = `
▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄
▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌
▀▀▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀█░▌
▐░▌▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌
▐░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄█░▌
▄▄▄▄▄▄▄▄▄█░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌ ▐░▌ ▐░▌ ▐░░░░░░░░░░░▌
▐░░░░░░░░░░░▌▐░█▀▀▀▀▀▀▀█░▌ ▀▀▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀█░▌
▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌
▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌ ▐░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░▐░▌ ▐░▌ ▐░▌
▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌ ▐░▌▐░░░░░░░░░░░▌ ▐░▌ ▐░▌ ▐░▌
▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀
`
console.log(msg);
}
})();