JSFiddle - React, Tailwind, and code Playground
by simonsarris
HTML
<canvas id="canvas1" width="200" height="200"></canvas>
CSS
canvas {
border: 1px solid gray;
}
JavaScript
var can = document.getElementById('canvas1');
var ctx = can.getContext('2d');
ctx.fillRect(50,50,50,50);
var img = new Image();
img.src = can.toDataURL();
document.body.appendChild(img);