root page, new layout
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
const canvas = document.getElementById('matrix-canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
|
||||
const letters = 'ABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVXYZ1234567890';
|
||||
const fontSize = 16;
|
||||
let columns = canvas.width / fontSize;
|
||||
|
||||
const drops = [];
|
||||
for (let x = 0; x < columns; x++) {
|
||||
drops[x] = 1;
|
||||
}
|
||||
|
||||
function draw() {
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
ctx.fillStyle = '#0F0'; // green text
|
||||
ctx.font = fontSize + 'px arial';
|
||||
|
||||
for (let i = 0; i < drops.length; i++) {
|
||||
const text = letters.charAt(Math.floor(Math.random() * letters.length));
|
||||
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
|
||||
|
||||
if (drops[i] * fontSize > canvas.height && Math.random() > 0.975) {
|
||||
drops[i] = 0;
|
||||
}
|
||||
drops[i]++;
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(draw, 33);
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
columns = canvas.width / fontSize;
|
||||
drops.length = 0;
|
||||
for (let x = 0; x < columns; x++) {
|
||||
drops[x] = 1;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user