-
Notifications
You must be signed in to change notification settings - Fork 1
/
easter_eggs.js
175 lines (152 loc) · 3.4 KB
/
easter_eggs.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
function show_snow () {
var duration = 15 * 1000;
var animationEnd = Date.now() + duration;
var skew = 1;
function randomInRange(min, max) {
return Math.random() * (max - min) + min;
}
(function frame() {
var timeLeft = animationEnd - Date.now();
var ticks = Math.max(200, 500 * (timeLeft / duration));
skew = Math.max(0.8, skew - 0.001);
confetti({
particleCount: 1,
startVelocity: 0,
ticks: ticks,
origin: {
x: Math.random(),
// since particles fall down, skew start toward the top
y: (Math.random() * skew) - 0.2
},
colors: ["#ffffff"],
shapes: ["circle"],
gravity: randomInRange(0.4, 0.6),
scalar: randomInRange(0.4, 1),
drift: randomInRange(-0.4, 0.4)
});
if (timeLeft > 0) {
requestAnimationFrame(frame);
}
}());
}
function _confetti () {
function confetti_a () {
confetti({
particleCount: 100,
spread: 70,
origin: { y: 0.6 }
});
}
function confetti_b () {
function randomInRange(min, max) {
return Math.random() * (max - min) + min;
}
confetti({
angle: randomInRange(55, 125),
spread: randomInRange(50, 70),
particleCount: randomInRange(50, 100),
origin: { y: 0.6 }
});
}
function confetti_c() {
var count = 200;
var defaults = {
origin: { y: 0.7 }
};
function fire(particleRatio, opts) {
confetti(Object.assign({}, defaults, opts, {
particleCount: Math.floor(count * particleRatio)
}));
}
fire(0.25, {
spread: 26,
startVelocity: 55,
});
fire(0.2, {
spread: 60,
});
fire(0.35, {
spread: 100,
decay: 0.91,
scalar: 0.8
});
fire(0.1, {
spread: 120,
startVelocity: 25,
decay: 0.92,
scalar: 1.2
});
fire(0.1, {
spread: 120,
startVelocity: 45,
});
}
function confetti_d () {
var defaults = {
spread: 360,
ticks: 50,
gravity: 0,
decay: 0.94,
startVelocity: 30,
shapes: ["star"],
colors: ["FFE400", "FFBD00", "E89400", "FFCA6C", "FDFFB8"]
};
function shoot() {
confetti({
...defaults,
particleCount: 40,
scalar: 1.2,
shapes: ["star"]
});
confetti({
...defaults,
particleCount: 10,
scalar: 0.75,
shapes: ["circle"]
});
}
setTimeout(shoot, 0);
setTimeout(shoot, 100);
setTimeout(shoot, 200);
}
async function confetti_e () {
$(".fireworks-container").show();
in_fireworks = true;
var fw = new Fireworks(document.querySelector(".fireworks-container"));
fw.start();
await delay(10000);
fw.stop();
in_fireworks = false;
$(".fireworks-container").html("").hide();
}
const confettiFunctions = [confetti_a, confetti_b, confetti_c, confetti_d, confetti_e];
const randomIndex = Math.floor(Math.random() * confettiFunctions.length);
const randomConfettiFunction = confettiFunctions[randomIndex];
try {
randomConfettiFunction();
} catch (error) {
console.warn(`Error executing ${randomConfettiFunction.name}: ${error}`);
}
}
function _next(value, multiple) {
return Math.ceil(value / multiple) * multiple;
}
async function easter_egg_fireworks (force=0) {
if(in_fireworks) {
return;
}
fireworks_counter++;
if(force || fireworks_counter) {
if(fireworks_counter % 10 == 0) {
_confetti();
}
if(fireworks_counter % 50 == 0) {
setAuroraBackground();
}
}
if(fireworks_counter < 50) {
log(`${fireworks_counter}/${_next(fireworks_counter, 10)}/${_next(fireworks_counter, 50)}`);
} else {
log(`${fireworks_counter}/${_next(fireworks_counter, 10)}`);
}
}