I am currently working on drawing shapes on a canvas, but I'm struggling with the rotation aspect. The tutorials I have come across so far have not been very helpful in solving this issue either due to my own lack of understanding or because they do not demonstrate interactive transformation methods, or maybe both.
I have written some code that allows me to draw shapes using the mousedown
, mousemove
, and mouseup
events. However, I would like to implement rotation functionality while the mousemove
point is at... (x1, y1)
- the starting point, and (x2, y2)
- the ending point. Feel free to provide suggestions on how to enhance the code snippet below:
context.strokeRect(x1, y1, x2-x1, y2-y1);
What modifications can I make to ensure that the rectangles follow the point (x2, y2)
when the button is held down?