Skip to content

Commit d9f89fb

Browse files
committed
Fixed lint error, added docs.
1 parent c239700 commit d9f89fb

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ one set of bindings ever created, which makes things a lot cleaner.
155155
* The Animation class now emits the `complete` event when it finishes playing on any Game Object.
156156
* The Animation Component has a new method called `chain` which allows you to line-up another animation to start playing as soon as the current one stops, no matter how it stops (either by reaching its natural end, or directly by having stop called on it). You can chain a new animation at any point, including before the current one starts playing, during it, or when it ends (via its `animationcomplete` callback). Chained animations are specific to a Game Object, meaning different Game Objects can have different chained animations without impacting the global animation they're playing.
157157
* `CanvasTexture.drawFrame` is a new method that allows you to draw a texture frame to the CanvasTexture based on the texture key and frame given.
158+
* `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.
159+
* `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.
158160

159161
### Updates
160162

src/textures/CanvasTexture.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,17 @@ var CanvasTexture = new Class({
310310
return out;
311311
},
312312

313+
/**
314+
* An object containing the position and color data for a single pixel in a CanvasTexture.
315+
*
316+
* @typedef {object} Phaser.Textures.CanvasTexture.PixelConfig
317+
*
318+
* @property {integer} x - The x-coordinate of the pixel.
319+
* @property {integer} y - The y-coordinate of the pixel.
320+
* @property {integer} color - The color of the pixel, not including the alpha channel.
321+
* @property {float} alpha - The alpha of the pixel, between 0 and 1.
322+
*/
323+
313324
/**
314325
* Returns an array containing all of the pixels in the given region.
315326
*
@@ -327,7 +338,7 @@ var CanvasTexture = new Class({
327338
* @param {integer} width - The width of the region to get. Must be an integer.
328339
* @param {integer} [height] - The height of the region to get. Must be an integer. If not given will be set to the `width`.
329340
*
330-
* @return {any[]} An array of Pixel objects.
341+
* @return {Phaser.Textures.CanvasTexture.PixelConfig[]} An array of Pixel objects.
331342
*/
332343
getPixels: function (x, y, width, height)
333344
{
@@ -351,9 +362,9 @@ var CanvasTexture = new Class({
351362

352363
for (var px = left; px < right; px++)
353364
{
354-
var pixel = this.getPixel(px, py, pixel);
365+
pixel = this.getPixel(px, py, pixel);
355366

356-
row.push({ x: px, y: py, color: pixel.color, alpha: pixel.alpha });
367+
row.push({ x: px, y: py, color: pixel.color, alpha: pixel.alphaGL });
357368
}
358369

359370
out.push(row);

0 commit comments

Comments
 (0)