D
D
DVirt2017-07-22 12:30:20
JavaScript
DVirt, 2017-07-22 12:30:20

How does canvas work when drawing individual shapes?

Hello.
I draw ordered figures on canvas. Each individual figure can be moved around the canvas (using DnD).
ab54c5c56ebe471f9da64a789378ee72.png
While moving the figure, the entire canvas is completely redrawn (as far as I understand), which is not effective for performance.
If I create an additional canvas element and during the animation I draw a single figure in it, and in the previous canvas (where all the figures are), I use clearRect on a certain area where the previously defined figure was placed before moving and at the end of the animation, redraw the entire main host.
Please clarify whether I am thinking correctly in this direction or how canvas works from the inside if I change at least one pixel on the canvas (it actually redraws the entire canvas or only one pixel)?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DVirt, 2017-07-22
@DVirt

Most of the answers I found here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question