Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Akhter Rasool
8,597 Pointscanvas drawing weird behaviour using jQuery
The contents of the canvas is too magnified, the lines are blurry and aren't joined together, and the line does not follow the mouse pointer and draws somewhere else when click and not at the point of pointer
here's my code:
// var $canvas = $("canvas");
// var context = $canvas[0].getContext("2d");
// var lastEvent;
// var mouseDown = false;
//
//
//
// $canvas.mousedown(function(e){
// lastEvent = e;
// mouseDown = true;
// }).mousemove(function(e){
// //draw lines
// e.preventDefault();
// if (mouseDown){
// context.beginPath();
// context.moveTo(lastEvent.offsetX, lastEvent.offsetY);
// context.lineTo(e.offsetX, e.offsetY);
//
// context.stroke();
// lastEvent = e;
//
// }
// }).mouseup(function(){
// mouseDown = false;
// });
//
//
// $canvas.mouseenter(function(e){
//
// console.log('x'+e.offsetX+' y-'+e.offsetY);
// }).mousemove(function(e){
// console.log('x'+e.offsetX+' y-'+e.offsetY);
// });
rydavim
18,814 Pointsrydavim
18,814 PointsIf you're still having issues with this, can you post a workspace snapshot so we can take a look at how all of your code works together? It's proving difficult to diagnose with just the bit you've posted.