<!
DOCTYPE html>
<html>
<head>
<title>Graphics Animation Example</title>
<style>
body {
background: #111;
color: white;
font-family: sans-serif;
text-align: center;
}
.css-box {
width: 80px;
height: 80px;
background: lime;
position: relative;
animation: moveBox 3s infinite ease-in-out;
margin: 20px auto;
}
@keyframes moveBox {
0% { left: 0px; background: lime; }
50% { left: 200px; background: cyan; }
100% { left: 0px; background: lime; }
}
canvas {
border: 2px solid #fff;
margin-top: 20px;
}
</style>
</head>
<body>
<h2>🌟 Graphics Animation in 1 HTML 🌟</h2>
<!-- CSS Animated Box -->
<div class="css-box"></div>
<!-- SVG Animation -->
<svg width="200" height="100">
<circle cx="50" cy="50" r="30" fill="orange">
<animate attributeName="cx" from="50" to="150" dur="2s"
repeatCount="indefinite" />
</circle>
</svg>
<!-- Canvas Bouncing Ball -->
<canvas id="myCanvas" width="300" height="150"></canvas>
<script>
const canvas = [Link]("myCanvas");
const ctx = [Link]("2d");
let x = 30;
let dx = 2;
function draw() {
[Link](0, 0, [Link], [Link]);
[Link]();
[Link](x, 75, 20, 0, [Link] * 2);
[Link] = "red";
[Link]();
x += dx;
if (x > [Link] - 20 || x < 20) dx = -dx;
requestAnimationFrame(draw);
}
draw();
</script>
</body>
</html>