Skip to content

Commit 0a35275

Browse files
committed
TransformMatrix.setToContext is a new method that will set the values from the Matrix to the given Canvas Rendering Context using setTransform rather than transform.
1 parent 22bc6d2 commit 0a35275

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/gameobjects/components/TransformMatrix.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ var TransformMatrix = new Class({
623623

624624
/**
625625
* Copy the values from this Matrix to the given Canvas Rendering Context.
626+
* This will use the Context.transform method.
626627
*
627628
* @method Phaser.GameObjects.Components.TransformMatrix#copyToContext
628629
* @since 3.12.0
@@ -640,6 +641,26 @@ var TransformMatrix = new Class({
640641
return ctx;
641642
},
642643

644+
/**
645+
* Copy the values from this Matrix to the given Canvas Rendering Context.
646+
* This will use the Context.setTransform method.
647+
*
648+
* @method Phaser.GameObjects.Components.TransformMatrix#setToContext
649+
* @since 3.12.0
650+
*
651+
* @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to.
652+
*
653+
* @return {CanvasRenderingContext2D} The Canvas Rendering Context.
654+
*/
655+
setToContext: function (ctx)
656+
{
657+
var matrix = this.matrix;
658+
659+
ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
660+
661+
return ctx;
662+
},
663+
643664
/**
644665
* Copy the values in this Matrix to the array given.
645666
*

0 commit comments

Comments
 (0)