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开发者_JAVA百科 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?
object.transform.matrix.tx
is equals to object.x
if no other transformation is applied (same for y
). If you draw something to the negative coordinates, the x
and y
properties of object
don't change.
object.x = 300;
object.y = 300;
object.graphics.beginFill(0);
object.graphics.drawCircle(0,0,100);
The bounding rect of the circle drawn in this example would start at -100,-100
but the object's center is still at 300,300
in the parent's coordinate space. Now getBounds
refers to the area of the object. The area's coordinates are converted to the parent's space and happen to be 200,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.
精彩评论