Js canvas drawing app in JavaScript Posted April 1, 2022 Been staring at this for hours, seen few tutorials and can't find the error. Can someone give me some direction. I believe this is suppose to let me draw but its doesn't. const canvas = document.querySelector("#canvas"); const ctx = canvas.getContext("2d"); canvas.height = window.innerHeight; canvas.width = window.innerWidth; let painting = false; function start(){ painting = true; } function end(){ painting = false; } function draw(e){ if (!painting) return; ctx.lineWidth = 10; ctx.lineCap = "round"; ctx.lineTo(e.clientX, e.clinetY) ctx.stroke(); } canvas.addEventListener("mousedown", start); canvas.addEventListener("mouseup", end); canvas.addEventListener("mousemove", draw);
Js canvas drawing app
in JavaScript
Posted
Been staring at this for hours, seen few tutorials and can't find the error. Can someone give me some direction. I believe this is suppose to let me draw but its doesn't.
const canvas = document.querySelector("#canvas");
const ctx = canvas.getContext("2d");
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
let painting = false;
function start(){
painting = true;
}
function end(){
painting = false;
}
function draw(e){
if (!painting) return;
ctx.lineWidth = 10;
ctx.lineCap = "round";
ctx.lineTo(e.clientX, e.clinetY)
ctx.stroke();
}
canvas.addEventListener("mousedown", start);
canvas.addEventListener("mouseup", end);
canvas.addEventListener("mousemove", draw);