JAVASCRIPT
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
let draw = false;
function startTri(e){
draw = true;
drawTri(e);
}
function endTri(){
draw = false;
}
function drawTri(e){
if(!draw) return;
ctx.lineWidth=3;
ctx.lineTo(e.clientX,e.clientY);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(e.clientX,e.clientY);
}
myCanvas.addEventListener("mousedown",startTri);
myCanvas.addEventListener("mouseup",endTri);
myCanvas.addEventListener("mousemove",drawTri);