Skip to content

Commit dcc66b3

Browse files
committed
added transformX() and transformY() methods
code is from openfl.geom.Matrix
1 parent 7815a0a commit dcc66b3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

flixel/math/FlxMatrix.hx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,30 @@ class FlxMatrix extends Matrix
6262
this.setTo(b, -a, d, -c, ty, -tx);
6363
return this;
6464
}
65+
66+
/**
67+
* Transforms x coordinate of the point.
68+
* Took original code from openfl.geom.Matrix (which isn't available on flash target).
69+
*
70+
* @param px x coordinate of the point
71+
* @param py y coordinate of the point
72+
* @return transformed x coordinate of the point
73+
*/
74+
public inline function transformX(px:Float, py:Float):Float
75+
{
76+
return px * a + py * c + tx;
77+
}
78+
79+
/**
80+
* Transforms y coordinate of the point.
81+
* Took original code from openfl.geom.Matrix (which isn't available on flash target).
82+
*
83+
* @param px x coordinate of the point
84+
* @param py y coordinate of the point
85+
* @return transformed y coordinate of the point
86+
*/
87+
public inline function transformY(px:Float, py:Float):Float
88+
{
89+
return px * b + py * d + ty;
90+
}
6591
}

0 commit comments

Comments
 (0)