You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,6 +161,8 @@ one set of bindings ever created, which makes things a lot cleaner.
161
161
*`CanvasTexture.getIndex` is a new method that will take an x/y coordinate and return the Image Data index offset used to retrieve the pixel values.
162
162
*`CanvasTexture.getPixels` is a new method that will take a region as an x/y and width/height and return all of the pixels in that region from the CanvasTexture.
163
163
*`CanvasTexture.setPixel` is a new method that sets the given pixel in the CanvasTexture to the color and alpha values provided.
164
+
*`CanvasTexture.getData` is a new method that will extract an ImageData block from the CanvasTexture from the region given.
165
+
*`CanvasTexture.putData` is a new method that will put an ImageData block at the given coordinates in a CanvasTexture.
Copy file name to clipboardExpand all lines: src/textures/CanvasTexture.js
+48Lines changed: 48 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -312,6 +312,54 @@ var CanvasTexture = new Class({
312
312
returnthis;
313
313
},
314
314
315
+
/**
316
+
* Puts the ImageData into the context of this CanvasTexture at the given coordinates.
317
+
*
318
+
* @method Phaser.Textures.CanvasTexture#putData
319
+
* @since 3.16.0
320
+
*
321
+
* @param {ImageData} imageData - The ImageData to put at the given location.
322
+
* @param {integer} x - The x coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer.
323
+
* @param {integer} y - The y coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer.
324
+
*
325
+
* @return {this} This CanvasTexture.
326
+
*/
327
+
putData: function(imageData,x,y)
328
+
{
329
+
x=Math.abs(Math.floor(x));
330
+
y=Math.abs(Math.floor(y));
331
+
332
+
this.context.putImageData(imageData,x,y);
333
+
334
+
returnthis;
335
+
},
336
+
337
+
/**
338
+
* Gets an ImageData region from this CanvasTexture from the position and size specified.
339
+
* You can write this back using `CanvasTexture.putData`, or manipulate it.
340
+
*
341
+
* @method Phaser.Textures.CanvasTexture#getData
342
+
* @since 3.16.0
343
+
*
344
+
* @param {integer} x - The x coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer.
345
+
* @param {integer} y - The y coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer.
346
+
* @param {integer} width - The width of the region to get. Must be an integer.
347
+
* @param {integer} height - The height of the region to get. Must be an integer.
348
+
*
349
+
* @return {ImageData} The ImageData extracted from this CanvasTexture.
0 commit comments