JSFiddle - React, Tailwind, and code Playground

by John kuoppala

HTML

<canvas id="canvas" width="500" height="300"></canvas>

JavaScript

var c = document.getElementById("canvas");
var ctx = c.getContext("2d");

var tile = new Image();
tile.src = "http://www.playspel.com/boom/images/grid-unknown.png";

for (var i = 0; i<(c.width/tile.width); i++) { //loop the rows
    for (var j = 0; j<(c.height/tile.height); j++) {// loop the columns for each row
        ctx.drawImage(tile,i*tile.width,j*tile.height);
    }
}