502502 </ ul >
503503 </ li >
504504
505+
505506 </ ul >
506507 </ div >
507508 </ div >
@@ -586,28 +587,37 @@ <h1 class="page-title">Source: gameobjects/BitmapData.js</h1>
586587 */
587588 this.imageData = this.context.getImageData(0, 0, width, height);
588589
590+ /**
591+ * @property {Uint8ClampedArray} data - A Uint8ClampedArray view into BitmapData.buffer.
592+ */
593+ this.data = this.imageData.data;
594+
595+ /**
596+ * @property {Uint32Array} pixels - An Uint32Array view into BitmapData.buffer.
597+ */
598+ this.pixels = null;
599+
589600 /**
590601 * @property {ArrayBuffer} buffer - An ArrayBuffer the same size as the context ImageData.
591602 */
592603 if (this.imageData.data.buffer)
593604 {
594605 this.buffer = this.imageData.data.buffer;
606+ this.pixels = new Uint32Array(this.buffer);
595607 }
596608 else
597609 {
598- this.buffer = new ArrayBuffer(this.imageData.data.length);
610+ if (window['ArrayBuffer'])
611+ {
612+ this.buffer = new ArrayBuffer(this.imageData.data.length);
613+ this.pixels = new Uint32Array(this.buffer);
614+ }
615+ else
616+ {
617+ this.pixels = this.imageData.data;
618+ }
599619 }
600620
601- /**
602- * @property {Uint8ClampedArray} data - A Uint8ClampedArray view into BitmapData.buffer.
603- */
604- this.data = this.imageData.data;
605-
606- /**
607- * @property {Uint32Array} pixels - An Uint32Array view into BitmapData.buffer.
608- */
609- this.pixels = new Uint32Array(this.buffer);
610-
611621 /**
612622 * @property {PIXI.BaseTexture} baseTexture - The PIXI.BaseTexture.
613623 * @default
@@ -786,19 +796,26 @@ <h1 class="page-title">Source: gameobjects/BitmapData.js</h1>
786796 if (typeof height === 'undefined') { height = this.height; }
787797
788798 this.imageData = this.context.getImageData(x, y, width, height);
799+ this.data = this.imageData.data;
789800
790801 if (this.imageData.data.buffer)
791802 {
792803 this.buffer = this.imageData.data.buffer;
804+ this.pixels = new Uint32Array(this.buffer);
793805 }
794806 else
795807 {
796- this.buffer = new ArrayBuffer(this.imageData.data.length);
808+ if (window['ArrayBuffer'])
809+ {
810+ this.buffer = new ArrayBuffer(this.imageData.data.length);
811+ this.pixels = new Uint32Array(this.buffer);
812+ }
813+ else
814+ {
815+ this.pixels = this.imageData.data;
816+ }
797817 }
798818
799- this.data = this.imageData.data;
800- this.pixels = new Uint32Array(this.buffer);
801-
802819 },
803820
804821 /**
@@ -840,7 +857,7 @@ <h1 class="page-title">Source: gameobjects/BitmapData.js</h1>
840857
841858 result = callback.call(callbackContext, pixel, tx, ty);
842859
843- if (result !== false && result !== null)
860+ if (result !== false && result !== null && result !== undefined )
844861 {
845862 this.setPixel32(tx, ty, result.r, result.g, result.b, result.a, false);
846863 dirty = true;
@@ -1128,6 +1145,8 @@ <h1 class="page-title">Source: gameobjects/BitmapData.js</h1>
11281145
11291146 /**
11301147 * Get the color of a specific pixel in the context into a color object.
1148+ * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer,
1149+ * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist.
11311150 *
11321151 * @method Phaser.BitmapData#getPixel
11331152 * @param {number} x - The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData.
@@ -1160,6 +1179,8 @@ <h1 class="page-title">Source: gameobjects/BitmapData.js</h1>
11601179
11611180 /**
11621181 * Get the color of a specific pixel including its alpha value.
1182+ * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer,
1183+ * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist.
11631184 * Note that on little-endian systems the format is 0xAABBGGRR and on big-endian the format is 0xRRGGBBAA.
11641185 *
11651186 * @method Phaser.BitmapData#getPixel32
@@ -1178,6 +1199,8 @@ <h1 class="page-title">Source: gameobjects/BitmapData.js</h1>
11781199
11791200 /**
11801201 * Get the color of a specific pixel including its alpha value as a color object containing r,g,b,a and rgba properties.
1202+ * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer,
1203+ * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist.
11811204 *
11821205 * @method Phaser.BitmapData#getPixelRGB
11831206 * @param {number} x - The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData.
@@ -1353,13 +1376,35 @@ <h1 class="page-title">Source: gameobjects/BitmapData.js</h1>
13531376
13541377 },
13551378
1379+ /**
1380+ * Draws a filled Rectangle to the BitmapData at the given x, y coordinates and width / height in size.
1381+ *
1382+ * @method Phaser.BitmapData#rect
1383+ * @param {number} x - The x coordinate of the top-left of the Rectangle.
1384+ * @param {number} y - The y coordinate of the top-left of the Rectangle.
1385+ * @param {number} width - The width of the Rectangle.
1386+ * @param {number} height - The height of the Rectangle.
1387+ * @param {string} [fillStyle] - If set the context fillStyle will be set to this value before the rect is drawn.
1388+ */
1389+ rect: function (x, y, width, height, fillStyle) {
1390+
1391+ if (typeof fillStyle !== 'undefined')
1392+ {
1393+ this.context.fillStyle = fillStyle;
1394+ }
1395+
1396+ this.context.fillRect(x, y, width, height);
1397+ this.context.fill();
1398+
1399+ },
1400+
13561401 /**
13571402 * Draws a filled Circle to the BitmapData at the given x, y coordinates and radius in size.
13581403 *
13591404 * @method Phaser.BitmapData#circle
1360- * @param {number} x - The x coordinate to draw the Circle at.
1361- * @param {number} y - The y coordinate to draw the Circle at.
1362- * @param {number} radius - The radius of the Circle.
1405+ * @param {number} x - The x coordinate to draw the Circle at. This is the center of the circle.
1406+ * @param {number} y - The y coordinate to draw the Circle at. This is the center of the circle.
1407+ * @param {number} radius - The radius of the Circle in pixels. The radius is half the diameter .
13631408 * @param {string} [fillStyle] - If set the context fillStyle will be set to this value before the circle is drawn.
13641409 */
13651410 circle: function (x, y, radius, fillStyle) {
@@ -1421,7 +1466,7 @@ <h1 class="page-title">Source: gameobjects/BitmapData.js</h1>
14211466
14221467 < span class ="jsdoc-message ">
14231468 Documentation generated by < a href ="https://github.com/jsdoc3/jsdoc "> JSDoc 3.3.0-dev</ a >
1424- on Tue Apr 29 2014 14:51:16 GMT+0100 (BST) using the < a href ="https://github.com/terryweiss/docstrap "> DocStrap template</ a > .
1469+ on Tue May 20 2014 10:05:49 GMT+0100 (BST) using the < a href ="https://github.com/terryweiss/docstrap "> DocStrap template</ a > .
14251470 </ span >
14261471 </ footer >
14271472 </ div >
0 commit comments