Skip to content

Commit 2ef28cd

Browse files
committed
Added getXRound and getYRound
1 parent 83bd4d7 commit 2ef28cd

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

src/gameobjects/components/TransformMatrix.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,58 @@ var TransformMatrix = new Class({
930930
return x * this.b + y * this.d + this.f;
931931
},
932932

933+
/**
934+
* Returns the X component of this matrix multiplied by the given values.
935+
*
936+
* This is the same as `x * a + y * c + e`, optionally passing via `Math.round`.
937+
*
938+
* @method Phaser.GameObjects.Components.TransformMatrix#getXRound
939+
* @since 3.50.0
940+
*
941+
* @param {number} x - The x value.
942+
* @param {number} y - The y value.
943+
* @param {boolean} [round=false] - Math.round the resulting value?
944+
*
945+
* @return {number} The calculated x value.
946+
*/
947+
getXRound: function (x, y, round)
948+
{
949+
var v = this.getX(x, y);
950+
951+
if (round)
952+
{
953+
v = Math.round(v);
954+
}
955+
956+
return v;
957+
},
958+
959+
/**
960+
* Returns the Y component of this matrix multiplied by the given values.
961+
*
962+
* This is the same as `x * b + y * d + f`, optionally passing via `Math.round`.
963+
*
964+
* @method Phaser.GameObjects.Components.TransformMatrix#getYRound
965+
* @since 3.50.0
966+
*
967+
* @param {number} x - The x value.
968+
* @param {number} y - The y value.
969+
* @param {boolean} [round=false] - Math.round the resulting value?
970+
*
971+
* @return {number} The calculated y value.
972+
*/
973+
getYRound: function (x, y, round)
974+
{
975+
var v = this.getY(x, y);
976+
977+
if (round)
978+
{
979+
v = Math.round(v);
980+
}
981+
982+
return v;
983+
},
984+
933985
/**
934986
* Returns a string that can be used in a CSS Transform call as a `matrix` property.
935987
*

0 commit comments

Comments
 (0)