HTML5 Canvas获取转换矩阵? [英] HTML5 Canvas get transform matrix?

查看:201
本文介绍了HTML5 Canvas获取转换矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种方法可以获得canvas的当前转换矩阵吗?有一个context.setTransform()函数,但似乎没有一个getTransform()等效的,只要我能告诉。

Is there a way to get the current transformation matrix for a canvas? There is a context.setTransform() function, but there does not seem to be a getTransform() equivalent as far as I can tell.

更具体地说,我想获得矩阵的当前比例和平移元素。 Google对此毫无帮助。

More specifically, I want to get the current scale and translation elements of the matrix. Google has been very unhelpful with this.

推荐答案

不,根本不是。 :

大多数canavs库(例如cake.js)已经实现了自己的矩阵类来跟踪当前的变换矩阵。

Most canavs libraries (such as cake.js) have instead implemented their own matrix class to keep track of the current transformation matrix.

cake.js的创建者认为没有办法获得当前的矩阵是荒谬的,足以保证

The creator of cake.js thought that there being no way to get the current matrix was ridiculous enough to warrant a bug report about it. Unfortunately that was back in 2007 and there has been no effort to include a getCurrentTransform in the spec.

2012年6月编辑:新规范包含一种获取当前转换矩阵的方法! context.currentTransform 可用于获取或设置当前转换矩阵。很遗憾没有浏览器实现它,虽然Firefox在它的上下文中有特定于供应商的 mozCurrentTransform 属性。所以你还不能使用它,但它在规格,所以很快!

Edit June 2012: The new specification does include a way to get the current transformation matrix! context.currentTransform can be used to get or set the current transformation matrix. Unfortunately no browsers have implemented it yet, though Firefox does have the vendor-specific mozCurrentTransform property on its context. So you can't use it just yet, but it is in the spec, so soon!

这篇关于HTML5 Canvas获取转换矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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