Jump to content

Js canvas drawing app


thre

Recommended Posts

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);

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...