JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id="canvas1" width="500" height="500"></canvas>
JavaScript
function drawShape(){
// get the canvas element using the DOM
var canvas = document.getElementById('canvas1');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
var ctxwidth = window.innerWidth;
// Filled triangle
ctx.canvas.width = window.innerWidth;
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(ctxwidth,0);
ctx.lineTo(0,105);
ctx.fillStyle="red"
ctx.fill();
}
}
drawShape();