JSFiddle - React, Tailwind, and code Playground
by adamschwartz
JavaScript
document.body.style.margin = 0;
document.documentElement.style.height = '100%';
document.body.style.height = '100%';
w = document.body.clientWidth;
h = document.body.clientHeight;
k = document.createElement('canvas');
k.width = w;
k.height = h;
document.body.appendChild(k);
c = k.getContext('2d');
// i = c.createImageData(1, 1);
// d = i.data;
// for (x = 0; x < w; x++) {
// for (y = 0; y < h; y++) {
// d[0] = r = Math.floor(Math.random() * 255);
// d[1] = g = Math.floor(Math.random() * 255);
// d[2] = b = Math.floor(Math.random() * 255);
// d[3] = a = 1;
// if (x < 10 && y < 10) {
// console.log(i, x, y);
// }
// c.putImageData(i, x, y);
// }
// }
setInterval(function(){
for (x = 0; x < w; x++) {
for (y = 0; y < h; y++) {
c.fillStyle = 'rgba(' + Math.floor(Math.random() * 255) + ', ' + Math.floor(Math.random() * 255) + ', ' + Math.floor(Math.random() * 255) + ', 1)';
c.fillRect(x, y, 1, 1);
}
}
}, 100);