finalizzazione del progetto
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
const canvas = document.getElementById('matrix-canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
|
||||
const symbols = '♻☘01RECYCLE-EARTH-SAVE-FUTURE';
|
||||
const fontSize = 16;
|
||||
const columns = canvas.width / fontSize;
|
||||
const drops = Array(Math.floor(columns)).fill(1);
|
||||
|
||||
function drawMatrix() {
|
||||
// Sfondo semi-trasparente per creare l'effetto scia
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
ctx.fillStyle = '#2ecc71'; // Il tuo verde brillante
|
||||
ctx.font = fontSize + 'px monospace';
|
||||
|
||||
for (let i = 0; i < drops.length; i++) {
|
||||
const text = symbols.charAt(Math.floor(Math.random() * symbols.length));
|
||||
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
|
||||
|
||||
if (drops[i] * fontSize > canvas.height && Math.random() > 0.975) {
|
||||
drops[i] = 0;
|
||||
}
|
||||
drops[i]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Avvia l'animazione
|
||||
setInterval(drawMatrix, 35);
|
||||
|
||||
// Adatta se l'utente ridimensiona la finestra
|
||||
window.addEventListener('resize', () => {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
});
|
||||
Reference in New Issue
Block a user