DEV Community

Discussion on: JavaScript mouse drawing on the canvas 👨‍🎨

Collapse
 
krhoyt profile image
Kevin Hoyt

Just wanted to second on using a line algorithm. If you draw with the mouse quickly, you will also see that the event does not fire with every pixel, so you get gaps in the data points. A line algorithm solves that, and can perform better depending on the algorithm and number of data points. Also consider pointer events or detecting touch for mobile support.

Collapse
 
dailydevtips1 profile image
Chris Bongers

Yes touch was indeed on the list still, but probably be a separate one, I like to keep the articles short so people will actually try them.
The line algorithm is a good one, I need to do some research on that.