Meta Description" name="description" />
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Love Animation</title>
<style>
body{
margin:0;
overflow:hidden;
background:black;
display:flex;
justify-content:center;
align-items:center;
height:100vh;
font-family:Arial, sans-serif;
}
canvas{
position:absolute;
}
h1{
position:absolute;
color:pink;
font-size:28px;
text-shadow:
0 0 10px pink,
0 0 20px hotpink,
0 0 40px deeppink;
animation:pulse 1.5s infinite;
}
@keyframes pulse{
0%,100%{
transform:scale(1);
}
50%{
transform:scale(1.1);
}
}
</style>
</head>
<body>
<h1>π I LOVE YOU π</h1>
<canvas id="heart"></canvas>
<script>
const canvas = document.getElementById("heart");
const ctx = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let particles = [];
function heartShape(t){
let x = 16 * Math.pow(Math.sin(t),3);
let y = 13*Math.cos(t)
- 5*Math.cos(2*t)
- 2*Math.cos(3*t)
- Math.cos(4*t);
return {
x:x,
y:y
};
}
for(let i=0; i<200; i++){
let t = Math.random() * Math.PI * 2;
let pos = heartShape(t);
particles.push({
x: canvas.width/2 + pos.x * 25,
y: canvas.height/2 - pos.y * 25,
text:"I love you",
size: 16 + Math.random()*6,
alpha: Math.random(),
speed: Math.random()*0.02 + 0.01
});
}
function animate(){
ctx.clearRect(0,0,canvas.width,canvas.height);
particles.forEach(p => {
p.alpha += p.speed;
if(p.alpha >= 1 || p.alpha <= 0){
p.speed *= -1;
}
ctx.save();
ctx.globalAlpha = p.alpha;
ctx.font = `${p.size}px Arial`;
ctx.fillStyle = "pink";
ctx.shadowColor = "hotpink";
ctx.shadowBlur = 15;
ctx.fillText(p.text, p.x, p.y);
ctx.restore();
});
requestAnimationFrame(animate);
}
animate();
window.addEventListener("resize", () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
});
</script>
</body>
</html>1
1
3KB
3KB
297.0ms
340.0ms
297.0ms