Skip to content

Commit c4c8b9e

Browse files
committed
Added copyToContext method
1 parent 674fc48 commit c4c8b9e

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ The process of managing scissors in the WebGLRenderer has been completely rewrit
5454
* The Canvas Renderer has a new method `setContext` which allows it to swap the context being drawn to by all draw operations. Call the method with no arguments to reset it to the default game canvas.
5555
* If you set `window.FORCE_WEBGL` or `window.FORCE_CANVAS` in the window in which the Phaser game is loaded it will over-ride the renderer type setting in your game config, and force either WebGL or Canvas. This is handy for quickly testing the differences between renderers without having to do a new build each time.
5656
* `TextureSource.source` is a new property that contains the original source of the Texture image. It is cleared when the source is destroyed.
57+
* `TransformMatrix.copyToContext` is a new method that will copy the values from the Matrix to the given Canvas Rendering Context.
5758

5859
### Updates
5960

src/gameobjects/components/TransformMatrix.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,25 @@ var TransformMatrix = new Class({
621621
return this;
622622
},
623623

624+
/**
625+
* Copy the values from this Matrix to the given Canvas Rendering Context.
626+
*
627+
* @method Phaser.GameObjects.Components.TransformMatrix#copyToContext
628+
* @since 3.12.0
629+
*
630+
* @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to.
631+
*
632+
* @return {CanvasRenderingContext2D} The Canvas Rendering Context.
633+
*/
634+
copyToContext: function (ctx)
635+
{
636+
var matrix = this.matrix;
637+
638+
ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
639+
640+
return ctx;
641+
},
642+
624643
/**
625644
* Copy the values in this Matrix to the array given.
626645
*
@@ -643,7 +662,6 @@ var TransformMatrix = new Class({
643662
}
644663
else
645664
{
646-
647665
out[0] = matrix[0];
648666
out[1] = matrix[1];
649667
out[2] = matrix[2];

0 commit comments

Comments
 (0)