JSFiddle - React, Tailwind, and code Playground

HTML

<canvas id="canvas"></canvas>

CSS

#canvas {
    background: #f00;
    width: 300px;
    height: 300px;
}

JavaScript

this.points = [{
    x: 100,
    y: 100
}, {
    x: 200,
    y: 100
}, {
    x: 200,
    y: 200
}, {
    x: 100,
    y: 200
}];

canvas.width = 300;
canvas.height = 300;
var sctx = canvas.getContext('2d');
sctx.save();
sctx.strokeStyle = this.color;
sctx.lineWidth = this.width;
sctx.beginPath();
sctx.moveTo(this.points[0].x, this.points[0].y);
for (var i = 1; i < this.points.length; i++)
{
    sctx.lineTo(this.points[i].x, this.points[i].y);
}
sctx.closePath();
sctx.stroke();
sctx.restore();