<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>ASCII Animation</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
}
canvas {
display: block;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
// Define the frames of the animation as an array of strings
const frames = [
" o \n /|\ \n / \ ",
" O \n / \ \n \ ",
" - \n |o> \n < \",
];
// Set up the canvas to fill the screen
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
resizeCanvas();
window.addEventListener("resize", resizeCanvas);
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
// Loop through the frames and display each one for 0.5 seconds
let frameIndex = 0;
setInterval(() => {
// Rotate the frame by frameIndex*45 degrees
const frame = frames[frameIndex % frames.length]
.replace("o", "*", 1)
.replace("-", "*", 1)
.replace("<", "|", 1)
.replace(">", "<", 1)
.replace("|", ">", 1)
.replace("*", "<", 1);
// Clear the canvas and draw the frame
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.font = "16px monospace";
ctx.fillText(frame, canvas.width / 2, canvas.height / 2);
// Increment the frame index
frameIndex++;
}, 500);
</script>
</body>
</html>