开发者

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

开发者 https://www.devze.com 2023-01-03 10:29 出处:网络
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

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消