This repository has been archived on 2024-04-03. You can view files and clone it, but cannot push or open issues or pull requests.
OLD-GZod01.fr_Source_Code-OLD/api/scripts/old.main.js

57 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2023-03-25 09:26:41 +00:00
let inactivityTime = function() {
let time;
window.onload = resetTimer;
document.onmousemove = resetTimer;
document.onkeypress = resetTimer;
function resetTimer() {
clearTimeout(time);
time = setTimeout(matrix, 2000)
}
};
window.onload = function() {
inactivityTime();
}
function matrix(){
let canvasnodecreation = document.createElement('canvas')
document.body.innerHTML=''
document.body.appendChild(canvasnodecreation)
var canvas = document.querySelector('canvas'),
ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
var letters = '010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101';
letters = letters.split('');
var fontSize = 10,
columns = canvas.width / fontSize;
var drops = [];
for (var i = 0; i < columns; i++) {
drops[i] = 1;
}
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;
}
}
}
setInterval(draw, 33);
}