<!DOCTYPE html>
<html>
<head>
<title>初音ミクの跳ね返るアスキーアート</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
margin: 0;
padding: 0;
background-color: #000000;
}
pre {
color: #00ff00;
font-size: 8px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<pre>
^\\/^
/ ^\/^\/^|
/ / /^|///|
∠( ̄^ ̄////|
_____| | ̄ ̄ ̄ ̄ ̄|ヽ
(ニニニニニ)| | | |
(ニニニニニニニ二ニニ)|______|
</pre>
<script>
const pre = document.querySelector("pre");
let x = 0;
let y = 0;
let dx = 1;
let dy = 1;
function animate() {
requestAnimationFrame(animate);
pre.style.transform = `translate(${x}px,${y}px)`;
x += dx;
y += dy;
if (x + pre.clientWidth >= window.innerWidth || x <= 0) {
dx = -dx;
}
if (y + pre.clientHeight >= window.innerHeight || y <= 0) {
dy = -dy;
}
}
animate();
</script>
</body>
</html>
(注:このコードを直接コピーすることは推奨されません。セキュリティ上の問題がある可能性があります。)
ジョーク:初音ミクが跳ね返っているのは、彼女が「絶対音感」であるためです。常に音の反響を感じ取っているんです!