使用transform.matrix和矩形.bounds绘制actionscript位图
我正在尝试从对象中获取部分位图,但我得到了不同的值:
object.transform.matrix.tx and object.transform.matrix.ty
v/s
object.getBounds(object.parent).x and object.getBounds(object.parent).y
我不确定在绘制位图数据时应该使用哪些值:
bitmapdata.draw(object, <matrix>);
要添加矩阵的 a、b、c、d 分量,请使用以下方法: 1,0,0,1(或身份)。那么有人可以解释一下在哪些场景中matrix.tx和matrix.ty与边界坐标不同吗?
I am trying to get a partial bitmap from an object but I am getting different values from:
object.transform.matrix.tx and object.transform.matrix.ty
v/s
object.getBounds(object.parent).x and object.getBounds(object.parent).y
I am not sure which ones should I use while drawing the bitmapdata:
bitmapdata.draw(object, <matrix>);
To add the a,b,c,d components of matrix are 1,0,0,1 (or identity). So Can someone explain in which scenarios are matrix.tx and matrix.ty different from bounds coordinates?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有应用其他转换,
object.transform.matrix.tx
等于object.x
(y
相同)。如果您将某些内容绘制到负坐标,则object
的x
和y
属性不会改变。本例中绘制的圆的边界矩形将从
-100,-100
开始,但对象的中心仍位于父对象的300,300
处坐标空间。现在getBounds
指的是对象的区域。该区域的坐标被转换为父级的空间,并且恰好是200,200
。父坐标空间中的矩阵平移和边界何时不同?
几乎总是,仅当对象的边界(在其自己的坐标空间中)从
0,0
开始时,它们才相同。文档中的
getBounds
示例。我无法告诉你应该使用哪一个,这取决于你需要在哪里绘制对象,但你没有提到所需的位置。object.transform.matrix.tx
is equals toobject.x
if no other transformation is applied (same fory
). If you draw something to the negative coordinates, thex
andy
properties ofobject
don't change.The bounding rect of the circle drawn in this example would start at
-100,-100
but the object's center is still at300,300
in the parent's coordinate space. NowgetBounds
refers to the area of the object. The area's coordinates are converted to the parent's space and happen to be200,200
.When are matrix translations and bounds in the parent's coordinate space different?
Almost always, they are only the same if the object's bound (in it's own coordinate space) start at
0,0
.This is partly covered by the example of
getBounds
in the documentation. I can't tell you which one should use, it depends on where you need to draw the object, but you haven't mentioned the desired position.