JSFiddle - React, Tailwind, and code Playground

HTML

<canvas id='example' width="1500px" height="300px">
      
    </canvas>

JavaScript

var canvas = document.getElementById("example");
var context = canvas.getContext("2d");

function drawLine(x1,y1,x2,y2)
{
    
    context.fillStyle = '#000';
    context.strokeStyle = '#000';


    context.beginPath();
    context.moveTo(x1, y1); 
    context.lineTo(x2, y2);
    context.lineWidth = 1;
    context.stroke();
    context.closePath();  
}    


drawLine(30,30,300,30);