JSFiddle - React, Tailwind, and code Playground

by Mobeen Sarwar

JavaScript

var canvas = document.createElement('canvas'),
    ctx = canvas.getContext('2d'),
    W,H,
    checked = 0;
canvas.width = W = 15;
canvas.height = H = 15;
document.body.appendChild(canvas);
(function loop(){
    ctx.fillStyle = '#ccc';
    ctx.fillRect(0,0,W,H);
    ctx.fillStyle = '#fff';
    ctx.fillRect(1,1,W-2,H-2);
    if(checked){
        ctx.fillStyle = '#000';
        ctx.fillRect(2,2,W-4,H-4);
    }
    setTimeout(loop,1000/60);
})();
canvas.onclick = function(){
    checked = !checked;
}