Why do we use canvas.save or canvas.restore?

I know what he is doing. If I do not use sometimes, I see a difference in alignments, sometimes I do not. My question is: if canvas.restore restores the state that precedes when it was saved, why arenโ€™t the changes made after the save, and before the restoration is canceled? Changes remain. Why?

+45
android
Jun 16 '10 at 9:14
source share
1 answer

canvas.save and canvas.restore actions such as rotation and translation. They do not cancel the drawing on the canvas. Android canvas works similarly to HTML5 canvas, so you can see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Transformations if you need more clarification.

+63
Jun 16 '10 at 15:05
source share



All Articles