如何重置为默认值

如何重置为默认值

本文介绍了HTML5 翻译方法,如何重置为默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 HTML5 的 translate-method 显然将绘图的原点相对于其原点移动.(当我连续使用 ctx.translate(20,20) 两次时,我得到的结果与使用 ctx.translate(40,40) 时的结果相同)那么现在的问题是我想将绘图的原点重置为其原始位置(它在第一次使用 translate() 之前的位置),我该怎么做?

Since HTML5's translate-method moves the origin of drawing relatively to its former origin apparently. (when I use ctx.translate(20,20) twice in a row I get the same result as when I use ctx.translate(40,40))Well now the problem is I'd like to reset the origin of drawing to its original position(the position it had before first useing of translate() on it), how do I do that?

推荐答案

ctx.setTransform(1, 0, 0, 1, 0, 0);

MDN setTransform 文档

这篇关于HTML5 翻译方法,如何重置为默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 06:16
查看更多