Today I wanted to continue canvas explorations by checking out how to draw on the canvas with our mouse. It turns out it's actually fairly simple and easy to implement! We'll be building this cool drawing app. (Have a play around!) https://codepen.io...

Markdown supported Β· ββ΅ to post
Great article! Thanks! I've made the "fixed-width" version, by setting the canvas size to copy it's parent wrapper's size.
ctx.canvas.width = canvas.offsetWidth;
ctx.canvas.height = canvas.offsetHeight;
codepen.io/frendhisaido_1470415284/pen/dyXypKB
But I'm still not sure why if the canvas is inside any parent that has a relative position, the mouse draw precision will be off by a few pixels.
Tapas Adhikary
Educator @tapaScript | Founder CreoWis & ReactPlay - Writer - YouTuber - Open Source
Great article, Chris Bongers!