JSFiddle - React, Tailwind, and code Playground
by Julien Etienne
JavaScript
// F U CSS!!
var canvas = document.createElement('canvas'),
body = document.getElementsByTagName('body')[0];
body.style.backgroundColor = '#222';
body.appendChild(canvas);
var cStyle = "background: red; width: 100%";
canvas.setAttribute("style", cStyle);
canvas.width = 1200;
canvas.height = 800;
// Context
var c = canvas.getContext('2d');
// The RAF
var rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {
return setTimeout(callback, 1000 / 60);
};
// The Loop
function loop() {
c.fillRect(0,0,canvas.width,canvas.height);
c.clearRect(0,0,canvas.width,canvas.height);
c.font = "16px arial";
c.fillText( new Date() , 10, 20);
rAF(loop);
}
// The Init
rAF(loop);