Skip to content

Instantly share code, notes, and snippets.

@jinnosux
Created October 30, 2024 14:52
Show Gist options
  • Save jinnosux/7e8c1de79ed2343f8862e841fc0a00a8 to your computer and use it in GitHub Desktop.
Save jinnosux/7e8c1de79ed2343f8862e841fc0a00a8 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>The Matrix</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
background: black;
}
</style>
</head>
<body>
<canvas id="c"></canvas>
<script>
var c = document.getElementById('c');
var ctx = c.getContext('2d');
c.height = window.innerHeight;
c.width = window.innerWidth;
var katakana = "゠クタハムヰアケチヒモヲィコッャンイツヤウゥサフュヵテユヶェショワエトヘヨォスラヱオナリカセニホル・ヌレーキソネロヽノマヮミ"
var characters = katakana.split('');
var fontSize = 24;
var columns = c.width / fontSize;
var drops = [];
for (var x = 0; x < columns; x++) {
drops[x] = 1;
}
function draw() {
ctx.fillStyle = "rgba(0, 0, 0, 0.05)";
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = "#0aff0a"; // green text
ctx.font = fontSize + "px arial";
for (var i = 0; i < drops.length; i++) {
var text = characters[Math.floor(Math.random() * characters.length)];
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
if (drops[i] * fontSize > c.height && Math.random() > 0.975) {
drops[i] = 0;
}
drops[i]++;
}
}
setInterval(draw, 35);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment