Created
October 6, 2023 01:25
-
-
Save breadchris/6c0ea9f2373bd7e82b6bd6ea84a3d843 to your computer and use it in GitHub Desktop.
Matrix for your OBS stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<style> | |
* {margin: 0; padding: 0} | |
canvas {display: block;} | |
</style> | |
<canvas id="canvas" width="150" height="150">The current time</canvas> | |
<script> | |
// Initialising the canvas | |
var canvas = document.querySelector('canvas'), | |
ctx = canvas.getContext('2d'); | |
// Setting the width and height of the canvas | |
canvas.width = window.innerWidth; | |
canvas.height = window.innerHeight; | |
// Setting up the letters | |
var letters = 'ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ'; | |
letters = letters.split(''); | |
// Setting up the columns | |
var fontSize = 10, | |
columns = canvas.width / fontSize; | |
// Setting up the drops | |
var drops = []; | |
for (var i = 0; i < columns; i++) { | |
drops[i] = 1; | |
} | |
// Setting up the draw function | |
function draw() { | |
ctx.fillStyle = 'rgba(0, 0, 0, .1)'; | |
ctx.fillRect(0, 0, canvas.width, canvas.height); | |
for (var i = 0; i < drops.length; i++) { | |
var text = letters[Math.floor(Math.random() * letters.length)]; | |
ctx.fillStyle = '#0f0'; | |
ctx.fillText(text, i * fontSize, drops[i] * fontSize); | |
drops[i]++; | |
if (drops[i] * fontSize > canvas.height && Math.random() > .95) { | |
drops[i] = 0; | |
} | |
} | |
} | |
// Loop the animation | |
setInterval(draw, 33); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment