-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
262 lines (217 loc) Β· 7.66 KB
/
index.html
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>π Happy Birthday π</title>
<style>
body {
margin: 0;
background: #000;
cursor: crosshair;
color: #fff;
font-family: "Comic Sans MS", cursive, sans-serif;
text-align: center;
}
canvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
#bdayPerson {
margin-top: 20px;
}
#greeting {
margin-top: 10px;
}
#bdayFooter {
margin-top: 20px;
margin-bottom: 10px;
}
h1 {
font-size: 5em;
font-weight: 900;
margin-bottom: 20px;
color: #FFD700; /* Increase brightness */
text-shadow: 2px 2px 4px #000000; /* Increase contrast */
}
#bdayFooter {
position: fixed;
bottom: 0;
left: 50%;
transform: translateX(-50%);
text-align: center;
color: white;
font-size: 18px;
padding: 10px 20px;
background-color: #000;
height: 50px;
}
@keyframes borderAnimation {
0% { border-color: rgb(0, 0, 0); }
25% { border-color: rgb(255, 0, 0); }
50% { border-color: rgb(0, 255, 0); }
75% { border-color: rgb(0, 0, 255); }
100% { border-color: rgb(255, 255, 255); }
}
#bdayPerson {
position: relative;
display: inline-block;
}
#bdayPerson img {
border: 2px solid rgb(0, 0, 0);
animation: borderAnimation 10s infinite alternate;
}
</style>
</head>
<body>
<h1>π Happy Birthday π</h1>
<canvas id="birthday"></canvas>
<div id="bdayPerson"><img src="bd.png" height="230", width="210" ></div>
<div id="greeting">
<p>"Happy Birthday, Biswajit! Words can't express how grateful I am to have you in my life. You're an amazing friend who always knows how to make me smile. Here's to another year of adventures and unforgettable memories! π"</p>
<p>You're more than just a friend, you're like My Misti. Thank you for always being there for me. I cherish every memory we've made together and I can't wait to create many more. Wishing you a birthday as special as you are! π₯³"</p>
<br>
<br>
<br>
<br>
<br>
</div>
<div id="bdayFooter">
<p>Crafted with heartfelt β€οΈ wishes for you by Mutelad! πππ</p>
</div>
<audio autoplay loop controls style="display: none;">
<source src="shot.mp3" type="audio/mpeg">
<source src="your_music_file.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
<script>
// helper functions
const PI2 = Math.PI * 2
const random = (min, max) => Math.random() * (max - min + 1) + min | 0
const timestamp = _ => new Date().getTime()
// container
class Birthday {
constructor() {
this.resize()
// create a lovely place to store the firework
this.fireworks = []
this.counter = 0
}
resize() {
this.width = canvas.width = window.innerWidth
let center = this.width / 2 | 0
this.spawnA = center - center / 4 | 0
this.spawnB = center + center / 4 | 0
this.height = canvas.height = window.innerHeight
this.spawnC = this.height * .1
this.spawnD = this.height * .5
}
onClick(evt) {
let x = evt.clientX || evt.touches && evt.touches[0].pageX
let y = evt.clientY || evt.touches && evt.touches[0].pageY
let count = random(3,5)
for(let i = 0; i < count; i++) this.fireworks.push(new Firework(
random(this.spawnA, this.spawnB),
this.height,
x,
y,
random(0, 260),
random(30, 110)))
this.counter = -1
}
update(delta) {
ctx.globalCompositeOperation = 'hard-light'
ctx.fillStyle = `rgba(20,20,20,${ 7 * delta })`
ctx.fillRect(0, 0, this.width, this.height)
ctx.globalCompositeOperation = 'lighter'
for (let firework of this.fireworks) firework.update(delta)
// if enough time passed... create new new firework
this.counter += delta * 3 // each second
if (this.counter >= 1) {
this.fireworks.push(new Firework(
random(this.spawnA, this.spawnB),
this.height,
random(0, this.width),
random(this.spawnC, this.spawnD),
random(0, 360),
random(30, 110)))
this.counter = 0
}
// remove the dead fireworks
if (this.fireworks.length > 2000) this.fireworks = this.fireworks.filter(firework => !firework.dead)
}
}
class Firework {
constructor(x, y, targetX, targetY, shade, offsprings) {
this.dead = false
this.offsprings = offsprings
this.x = x
this.y = y
this.targetX = targetX
this.targetY = targetY
this.shade = shade
this.history = []
}
update(delta) {
if (this.dead) return
let xDiff = this.targetX - this.x
let yDiff = this.targetY - this.y
if (Math.abs(xDiff) > 3 || Math.abs(yDiff) > 3) { // is still moving
this.x += xDiff * 2 * delta
this.y += yDiff * 2 * delta
this.history.push({
x: this.x,
y: this.y
})
if (this.history.length > 20) this.history.shift()
} else {
if (this.offsprings && !this.madeChilds) {
let babies = this.offsprings / 2
for (let i = 0; i < babies; i++) {
let targetX = this.x + this.offsprings * Math.cos(PI2 * i / babies) | 0
let targetY = this.y + this.offsprings * Math.sin(PI2 * i / babies) | 0
birthday.fireworks.push(new Firework(this.x, this.y, targetX,
targetY, this.shade, 0))
}
}
this.madeChilds = true
this.history.shift()
}
if (this.history.length === 0) this.dead = true
else if (this.offsprings) {
for (let i = 0; this.history.length > i; i++) {
let point = this.history[i]
ctx.beginPath()
ctx.fillStyle = 'hsl(' + this.shade + ',100%,' + i + '%)'
ctx.arc(point.x, point.y, 1, 0, PI2, false)
ctx.fill()
}
} else {
ctx.beginPath()
ctx.fillStyle = 'hsl(' + this.shade + ',100%,50%)'
ctx.arc(this.x, this.y, 1, 0, PI2, false)
ctx.fill()
}
}
}
let canvas = document.getElementById('birthday')
let ctx = canvas.getContext('2d')
let then = timestamp()
let birthday = new Birthday
window.onresize = () => birthday.resize()
document.onclick = evt => birthday.onClick(evt)
document.ontouchstart = evt => birthday.onClick(evt)
;(function loop(){
requestAnimationFrame(loop)
let now = timestamp()
let delta = now - then
then = now
birthday.update(delta / 1000)
})()
</script>
</body>
</html>