-
Notifications
You must be signed in to change notification settings - Fork 3
/
fyu.js
120 lines (103 loc) · 3.16 KB
/
fyu.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
}
var elems;
async function shiftHorizontalRandom() { // Shifts each element randomly left or right 4 times per second
while (true) {
for (elem in elems) {
elems[elem].style.transform = "none";
elems[elem].style.transform = `translateX(${getRandomInt(-250, 100)}px)`;
};
await sleep(250);
};
};
async function shiftVerticalRandom() { // Shifts each element randomly up or down 4 times per second
while (true) {
for (elem in elems) {
elems[elem].style.transform = "none";
elems[elem].style.transform = `translateY(${getRandomInt(-250, 100)}px)`;
};
await sleep(250);
};
};
async function shiftRandom() { // Shifts each element randomly around the screen 4 times per second
shiftHorizontalRandom();
shiftVerticalRandom();
};
async function rotateRandom() { // Rotates each element randomly 4 times per second
while (true) {
for (elem in elems) {
elems[elem].style.transform = `rotate(${getRandomInt(0, 359)}deg)`;
};
await sleep(250);
};
};
async function runAway() { // Makes every element "run away" from the cursor when hovered over
for (elem in elems) {
elems[elem].addEventListener('mouseover', moveFromMouse);
};
while (true) {
await sleep(250);
};
};
async function moveFromMouse(e) { // The actual funtion run by runAway()
e.target.style.transform = "none";
e.target.style.transform = `translate(${getRandomInt(-150, 50)}px, ${getRandomInt(-150, 50)}px)`;
}
async function colorsRandom() { // Changes every element's color and background color every 2.5 seconds
while (true) {
for (elem in elems) {
let currentBack = elems[elem].style.backgroundColor;
let currentColor = elems[elem].style.color;
elems[elem].animate([
// keyframes ${getRandomInt(0, 256)}
{ backgroundColor: currentBack, color: currentColor },
{ backgroundColor: `rgb(${getRandomInt(0, 256)},${getRandomInt(0, 256)},${getRandomInt(0, 256)})`, color: `rgb(${getRandomInt(0, 256)},${getRandomInt(0, 256)},${getRandomInt(0, 256)})` },{ backgroundColor: currentBack, color: currentColor }
], {
// timing options
duration: 2500,
easing: 'ease-in-out',
iterations: 1
});
};
await sleep(2500);
};
};
async function opacityRandom() { // Changes every element's opacity every 5 seconds
while (true) {
for (elem in elems) {
elems[elem].animate([
// keyframes
{ opacity: 1 },
{ opacity: Math.random() * 2 }, // yes i know this is out of range just shut up i want things to be more opaque than not more often
{ opacity: 1 }
], {
// timing options
duration: 5000,
easing: 'ease-in-out',
iterations: 1
});
};
await sleep(5000);
};
};
function loadElems() {
elems = Array.from(document.getElementsByTagName("*"));
for (elem in elems) {
if (elems[elem].classList.contains('dontNuke')) {
delete elems[elem];
};
};
}
async function makeItHell() {
loadElems();
shiftRandom();
runAway();
colorsRandom();
opacityRandom();
};