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

I know what it does. If I dont use sometimes I can see the difference in alignments, sometimes I don't. My question is: if canvas.restore restores the state previous to when it was saved, why aren't the changes made after save and before restore undone? The changes remain. Why?


Solution 1:

canvas.save and canvas.restore undo things like rotation and translation. They don't undo drawing on the canvas. The android canvas works similarly to the HTML5 canvas, so you can look at https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Transformations if you need more clarification.