Answer the question
In order to leave comments, you need to log in
Animating and moving objects in canvas?
Help me understand a couple of things with canvas:
1. If an object (a point, for example) is already drawn on the canvas, then nothing can be done with it (move or change color)?
2. From the first it follows that you need to erase the entire canvas, store these objects in an array and draw again?
3. Why don't many people write ctx.closePath();
?
4. There is no access to objects like in SVG to hang event handlers?
5. If so, then it turns out again that all objects must be entered into an array and the mouse coordinates calculated, etc.?
Answer the question
In order to leave comments, you need to log in
1. Yes.
2. Yes. You can look at the Graphics2D.js sources, it does exactly that.
3. Write when you need to close the path.
4. No.
5. Yes. But there is good news, there is isPointInPath on canvas. Again, you can look at the sources of Graphics2D) If you have questions about them, contact the PM on Habré.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question