JSFiddle - React, Tailwind, and code Playground

by Akihiko Kusanagi

HTML

<div style="background-color:gray">
<canvas id="canvas"></canvas>
</div>

JavaScript

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

ctx.beginPath();
ctx.moveTo(20, 20);
ctx.lineTo(200, 20);
ctx.lineTo(200, 120);
ctx.closePath();
ctx.lineTo(20, 120);
//ctx.closePath(); // draws last line of the triangle
//ctx.rect(0, 0, 150, 150);
ctx.stroke();