为什么要使用canvas.save或canvas.restore? [英] Why do we use canvas.save or canvas.restore?

查看:128
本文介绍了为什么要使用canvas.save或canvas.restore?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道它做什么。如果我不使用,有时我能看到路线的差异,有时我不知道。我的问题是:如果 canvas.restore 恢复状态previous来保存它的时候,为什么没有作出后保存和恢复之前,百废待兴的变化?这些变化仍然存在。为什么呢?

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 canvas.restore 撤消像旋转和平移。他们不撤消在画布上绘制。 Android的画布上的工作方式类似于HTML5的画布,所以你可以看看<一href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Transformations">https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Transformations如果你需要更多的澄清。

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.

这篇关于为什么要使用canvas.save或canvas.restore?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆