Program for Birthday Celebration (1)
Program for Birthday Celebration (1)
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link
href="https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&family=Poppi
ns:wght@300;500;700&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/TextPlugin.min.js"></script>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
body, html {
width: 100%;
height: 100%;
overflow: hidden;
.background {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -2;
#starCanvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
#fireworksCanvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
#petalsCanvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
pointer-events: none;
.birthday-text {
color: white;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
opacity: 0;
font-weight: 700;
white-space: nowrap;
font-size: 100px;
}
.romantic-message {
text-align: center;
position: absolute;
top: 60%;
left: 50%;
opacity: 0;
font-weight: 300;
font-size: 1.2rem;
letter-spacing: 1px;
width: 80%;
max-width: 600px;
.hearts-container {
position: absolute;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 2;
.heart {
position: absolute;
width: 30px;
height: 30px;
opacity: 0;
transform: scale(0);
.birthday-container {
position: relative;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 5;
.celebrate-button {
position: absolute;
bottom: 20%;
left: 50%;
border-radius: 50px;
font-weight: 500;
letter-spacing: 2px;
border: none;
cursor: pointer;
font-size: 18px;
opacity: 0;
overflow: hidden;
.celebrate-button::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
opacity: 0;
transform: scale(0.5);
.celebrate-button:hover {
.celebrate-button:hover::before {
opacity: 1;
transform: scale(1);
.celebrate-button:active {
.letter {
display: inline-block;
opacity: 0;
transform: translateY(20px);
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
.glow-effect {
.birthday-text {
font-size: 3.5rem;
width: 100%;
padding: 0 20px;
.romantic-message {
font-size: 1rem;
top: 65%;
.celebrate-button {
bottom: 15%;
font-size: 16px;
}
@media screen and (max-width: 480px) {
.birthday-text {
font-size: 2.5rem;
.romantic-message {
font-size: 0.9rem;
width: 90%;
.celebrate-button {
bottom: 10%;
font-size: 14px;
.next-page-button {
position: fixed;
bottom: 10px;
right: 10px;
border-radius: 5px;
color: white;
font-weight: 500;
letter-spacing: 1px;
border: none;
cursor: pointer;
font-size: 14px;
opacity: 0;
overflow: hidden;
.next-page-button:hover {
transform: scale(1.05);
.next-page-button:active {
transform: scale(0.98);
</style>
</head>
<body>
<div class="background"></div>
<canvas id="starCanvas"></canvas>
<canvas id="petalsCanvas"></canvas>
<canvas id="fireworksCanvas"></canvas>
<div class="birthday-container">
</div>
<script>
// Canvas elements
function resizeCanvas() {
starCanvas.width = window.innerWidth;
starCanvas.height = window.innerHeight;
fireworksCanvas.width = window.innerWidth;
fireworksCanvas.height = window.innerHeight;
petalsCanvas.width = window.innerWidth;
petalsCanvas.height = window.innerHeight;
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
class Star {
constructor() {
this.reset();
reset() {
this.glowFactor = Math.random() * 15 + 5;
r: 255,
};
update() {
if (this.growing) {
this.size += this.speed;
this.growing = false;
} else {
this.size -= this.speed;
this.growing = true;
}
// Occasionally reset for more dynamic movement
this.reset();
draw() {
this.x, this.y, 0,
);
starCtx.fillStyle = glow;
starCtx.beginPath();
starCtx.fill();
starCtx.beginPath();
starCtx.fill();
}
}
class Petal {
constructor() {
this.reset();
reset() {
this.y = -20;
this.size = Math.random() * 15 + 8;
this.speedX = Math.random() * 2 - 1;
this.rotationSpeed = Math.random() * 2 - 1;
this.color = {
g: Math.floor(Math.random() * 50),
b: Math.floor(Math.random() * 80) + 50
};
update() {
this.y += this.speedY;
this.x += Math.sin(this.y * 0.01) + this.speedX;
this.rotation += this.rotationSpeed;
this.reset();
draw() {
petalsCtx.save();
petalsCtx.translate(this.x, this.y);
petalsCtx.beginPath();
petalsCtx.moveTo(0, 0);
petalsCtx.bezierCurveTo(
this.size / 2, -this.size / 4,
this.size, -this.size / 2,
0, -this.size
);
petalsCtx.bezierCurveTo(
-this.size, -this.size / 2,
-this.size / 2, -this.size / 4,
0, 0
);
// Fill with gradient
petalsCtx.fillStyle = gradient;
petalsCtx.fill();
petalsCtx.restore();
class FireworkParticle {
constructor(x, y, color) {
this.x = x;
this.y = y;
this.color = color;
this.radius = Math.random() * 3 + 1;
this.velocity = {
x: (Math.random() - 0.5) * 8,
y: (Math.random() - 0.5) * 8
};
this.gravity = 0.04;
this.friction = 0.97;
this.opacity = 1;
this.remainingLife = this.life;
update() {
this.velocity.y += this.gravity;
this.velocity.x *= this.friction;
this.velocity.y *= this.friction;
this.x += this.velocity.x;
this.y += this.velocity.y;
this.remainingLife--;
draw() {
fireworksCtx.beginPath();
fireworksCtx.fill();
);
fireworksCtx.fillStyle = glow;
fireworksCtx.beginPath();
fireworksCtx.fill();
// Heart-shaped firework
class HeartFirework {
constructor() {
this.y = fireworksCanvas.height;
this.destination = {
};
this.velocity = {
};
this.particles = [];
this.color = {
g: Math.floor(Math.random() * 50),
b: Math.floor(Math.random() * 80) + 50
};
this.trail = [];
this.exploded = false;
update() {
if (!this.exploded) {
this.x += this.velocity.x;
this.y += this.velocity.y;
// Add trail
this.trail.push({
x: this.x,
y: this.y,
opacity: 1
});
// Update trail
if (this.trail[i].opacity <= 0) {
this.trail.splice(i, 1);
i--;
Math.pow(this.x - this.destination.x, 2) +
Math.pow(this.y - this.destination.y, 2)
);
this.explode();
} else {
this.particles[i].update();
if (this.particles[i].remainingLife <= 0) {
this.particles.splice(i, 1);
i--;
}
explode() {
this.exploded = true;
heartPoints.push({
});
this.particles.push(particle);
}
draw() {
if (!this.exploded) {
// Draw trail
fireworksCtx.beginPath();
fireworksCtx.fill();
fireworksCtx.beginPath();
fireworksCtx.fill();
} else {
this.particles[i].draw();
}
// Standard firework class
class Firework {
constructor() {
this.y = fireworksCanvas.height;
this.destination = {
x: Math.random() * fireworksCanvas.width,
};
this.velocity = {
};
this.particles = [];
this.color = {
b: Math.floor(Math.random() * 255)
};
this.trail = [];
this.exploded = false;
update() {
if (!this.exploded) {
this.x += this.velocity.x;
this.y += this.velocity.y;
// Add trail
this.trail.push({
x: this.x,
y: this.y,
opacity: 1
});
// Update trail
this.trail[i].opacity -= 0.025;
if (this.trail[i].opacity <= 0) {
this.trail.splice(i, 1);
i--;
Math.pow(this.x - this.destination.x, 2) +
Math.pow(this.y - this.destination.y, 2)
);
this.explode();
}
} else {
this.particles[i].update();
if (this.particles[i].remainingLife <= 0) {
this.particles.splice(i, 1);
i--;
explode() {
this.exploded = true;
draw() {
if (!this.exploded) {
// Draw trail
fireworksCtx.beginPath();
fireworksCtx.fill();
fireworksCtx.beginPath();
fireworksCtx.fill();
} else {
this.particles[i].draw();
// Create stars
stars.push(new Star());
// Create petals
let fireworksInterval;
let heartFireworksInterval;
function addFirework() {
fireworks.push(new HeartFirework());
} else {
fireworks.push(new Firework());
function addFloatingHeart() {
heart.className = 'heart';
heart.innerHTML = `
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0
3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55
11.54L12 21.35z"
fill="rgba(255, ${Math.random() * 100}, ${Math.random() * 100},
${Math.random() * 0.4 + 0.6})"/>
</svg>
`;
heartsContainer.appendChild(heart);
// Animate heart
gsap.to(heart, {
opacity: 1,
scale: 1,
duration: 0.5,
onComplete: () => {
gsap.to(heart, {
opacity: 0,
scale: 0.5,
duration: 4 + Math.random() * 4,
ease: "power1.out",
onComplete: () => {
heart.remove();
});
}
});
// Animate stars
function animateStars() {
stars.forEach(star => {
star.update();
star.draw();
});
requestAnimationFrame(animateStars);
// Animate petals
function animatePetals() {
petals.forEach(petal => {
petal.update();
petal.draw();
});
requestAnimationFrame(animatePetals);
}
// Animate fireworks
function animateFireworks() {
fireworks[i].update();
fireworks[i].draw();
fireworks.splice(i, 1);
i--;
requestAnimationFrame(animateFireworks);
function startFireworks() {
// Regular fireworks
setTimeout(() => {
clearInterval(fireworksInterval);
}, 5000);
// Heart fireworks
setTimeout(() => {
clearInterval(heartFireworksInterval);
}, 4000);
window.addEventListener('load', () => {
// Start animations
animateStars();
animatePetals();
animateFireworks();
startFireworks();
birthdayText.textContent = '';
letter.textContent = text[i];
letter.className = 'letter';
birthdayText.appendChild(letter);
}
setTimeout(() => {
birthdayText.style.opacity = 1;
gsap.to(letter, {
opacity: 1,
y: 0,
duration: 0.6,
ease: "back.out(1.7)"
});
});
gsap.to(birthdayText, {
textShadow: "0 0 20px rgba(255, 255, 255, 0.8), 0 0 40px rgba(255, 123, 172, 0.4)",
duration: 1.5
});
gsap.to(celebrateBtn, {
opacity: 1,
scale: 1,
duration: 0.8,
});
let hoverEffect = 0;
celebrateBtn.addEventListener('mouseenter', () => {
hoverEffect = (hoverEffect + 1) % 3;
switch(hoverEffect) {
gsap.to(celebrateBtn, {
boxShadow: "0 7px 25px rgba(255, 123, 172, 0.8), 0 0 40px rgba(255, 123,
172, 0.6)",
duration: 0.4
});
break;
gsap.to(celebrateBtn, {
y: -10,
duration: 0.4,
yoyo: true,
repeat: 1,
ease: "power2.inOut"
});
break;
gsap.to(celebrateBtn, {
scale: 1.1,
duration: 0.4,
ease: "power1.out"
});
break;
});
celebrateBtn.addEventListener('mouseleave', () => {
gsap.to(celebrateBtn, {
boxShadow: "0 5px 15px rgba(255, 123, 172, 0.4), 0 0 20px rgba(255, 123, 172,
0.2)",
y: 0,
scale: 1,
duration: 0.4
});
});
const nextPageBtn = document.getElementById('nextPageBtn');
nextPageBtn.addEventListener('click', () => {
});
gsap.to(nextPageBtn, {
opacity: 1,
duration: 0.8,
});
celebrateBtn.addEventListener('click', () => {
gsap.to(celebrateBtn, {
scale: 0.95,
duration: 0.1,
onComplete: () => {
startFireworks();
gsap.to(celebrateBtn, {
scale: 1,
duration: 0.5,
});
});
});
}, 3000);
});
</script>
</body>
</html>