I have an HTML canvas element and implemented a brush that captures the mousedown , mousemove and mouseup events of the canvas element. All this is great for painting on canvas. However, I donβt think I like the way you canβt continue drawing if your mouse exits the middle beat canvas. It just chopped off. This is very inexorable for a person and, in my opinion, not very convenient.
If you open Microsoft Paint and start painting with a brush or ellipse or something else, until you start working with the canvas, you can drag and drop anywhere on the screen and enter the canvas again. It also makes it easier, for example, to draw a quarter circle in the corners, because you can drag the ellipse tool off the screen. Hope this makes sense.
In any case, I was wondering if there is a way to implement this using an HTML5 canvas, or how I will implement these kinds of things. A user would never have to see something painted there; it is basically just a feature for ease of use.
Edit: The problem with many of these solutions is how to handle the coordinates. Currently, my canvas is in the middle of the screen, and the upper left canvas is (0, 0) and the lower right is (500, 500) . The work of translating coordinates should also be considered.
Edit2: I found out that, apparently, you can easily remove the borders of the canvas. For example, you can specify a negative width, height, and coordinates, and the canvas element will handle this just fine. Therefore, in general, the solution is likely to require only capturing the mousemove and mouseup document and just translating x and y to start in the upper left corner of the canvas.