JSFiddle - React, Tailwind, and code Playground
by claykaboom
HTML
<p>Canvas to fill:</p>
<canvas id="myCanvas" width="300" height="300"
style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
JavaScript
myCanvas();
function myCanvas() {
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
// var img = document.getElementById("scream");
// ctx.drawImage(img,10,10);
ctx.fillStyle = '#f25555';
ctx.beginPath();
ctx.moveTo(0, 300);
ctx.lineTo(300,0);
ctx.lineTo(300, 300);
ctx.closePath();
ctx.fill();
ctx.fillStyle = '#55f255';
ctx.beginPath();
ctx.moveTo(0, 300);
ctx.lineTo(0, 0);
ctx.lineTo(300,0);
ctx.closePath();
ctx.fill();
ctx.moveTo(0,300);
ctx.lineTo(300,0);
ctx.stroke();
}