Skip to content

Commit f036583

Browse files
committed
Pixi 1.6.1
1 parent 2c421d2 commit f036583

7 files changed

Lines changed: 188 additions & 65 deletions

File tree

src/pixi/Pixi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PIXI.WEBGL_RENDERER = 0;
1616
PIXI.CANVAS_RENDERER = 1;
1717

1818
// useful for testing against if your lib is using pixi.
19-
PIXI.VERSION = "v1.6";
19+
PIXI.VERSION = "v1.6.1";
2020

2121

2222
// the various blend modes supported by pixi

src/pixi/display/DisplayObjectContainer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', {
4242
return this.scale.x * this.getLocalBounds().width;
4343
},
4444
set: function(value) {
45+
4546
this.scale.x = value / (this.getLocalBounds().width/this.scale.x);
4647
this._width = value;
4748
}

src/pixi/extras/TilingSprite.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ PIXI.TilingSprite = function(texture, width, height)
2222
* @property width
2323
* @type Number
2424
*/
25-
this.width = width || 100;
25+
this._width = width || 100;
2626

2727
/**
2828
* The height of the tiling sprite
2929
*
3030
* @property height
3131
* @type Number
3232
*/
33-
this.height = height || 100;
33+
this._height = height || 100;
3434

3535
/**
3636
* The scaling of the image that is being tiled
@@ -82,6 +82,9 @@ PIXI.TilingSprite = function(texture, width, height)
8282
* @default PIXI.blendModes.NORMAL;
8383
*/
8484
this.blendMode = PIXI.blendModes.NORMAL;
85+
86+
87+
8588
};
8689

8790
// constructor
@@ -141,22 +144,23 @@ PIXI.TilingSprite.prototype.setTexture = function(texture)
141144
PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
142145
{
143146
if (this.visible === false || this.alpha === 0) return;
144-
145147
var i,j;
146148

147-
if (this.mask)
149+
if (this._mask)
148150
{
149151
renderSession.spriteBatch.stop();
150152
renderSession.maskManager.pushMask(this.mask, renderSession);
151153
renderSession.spriteBatch.start();
152154
}
153155

154-
if (this.filters)
156+
if (this._filters)
155157
{
156158
renderSession.spriteBatch.flush();
157159
renderSession.filterManager.pushFilter(this._filterBlock);
158160
}
159161

162+
163+
160164
if (!this.tilingTexture || this.refreshTexture)
161165
{
162166
this.generateTilingTexture(true);
@@ -173,7 +177,6 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
173177
{
174178
renderSession.spriteBatch.renderTilingSprite(this);
175179
}
176-
177180
// simple render children!
178181
for (i=0,j=this.children.length; i<j; i++)
179182
{
@@ -182,8 +185,8 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
182185

183186
renderSession.spriteBatch.stop();
184187

185-
if (this.filters) renderSession.filterManager.popFilter();
186-
if (this.mask) renderSession.maskManager.popMask(renderSession);
188+
if (this._filters) renderSession.filterManager.popFilter();
189+
if (this._mask) renderSession.maskManager.popMask(renderSession);
187190

188191
renderSession.spriteBatch.start();
189192
};
@@ -346,6 +349,21 @@ PIXI.TilingSprite.prototype.getBounds = function()
346349
return bounds;
347350
};
348351

352+
353+
354+
/**
355+
* When the texture is updated, this event will fire to update the scale and frame
356+
*
357+
* @method onTextureUpdate
358+
* @param event
359+
* @private
360+
*/
361+
PIXI.TilingSprite.prototype.onTextureUpdate = function()
362+
{
363+
// overriding the sprite version of this!
364+
};
365+
366+
349367
/**
350368
*
351369
* @method generateTilingTexture

src/pixi/primitives/Graphics.js

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ PIXI.Graphics.prototype.lineTo = function(x, y)
221221
* Calculate the points for a quadratic bezier curve.
222222
* Based on : https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c
223223
*
224+
* @method quadraticCurveTo
224225
* @param {number} cpX Control point x
225226
* @param {number} cpY Control point y
226227
* @param {number} toX Destination point x
@@ -229,13 +230,15 @@ PIXI.Graphics.prototype.lineTo = function(x, y)
229230
*/
230231
PIXI.Graphics.prototype.quadraticCurveTo = function(cpX, cpY, toX, toY)
231232
{
232-
// this.currentPath.points.push(toX, toY)
233-
//return;
233+
if( this.currentPath.points.length === 0)this.moveTo(0,0);
234+
234235
var xa,
235236
ya,
236237
n = 20,
237238
points = this.currentPath.points;
239+
if(points.length === 0)this.moveTo(0, 0);
238240

241+
239242
var fromX = points[points.length-2];
240243
var fromY = points[points.length-1];
241244

@@ -260,6 +263,7 @@ PIXI.Graphics.prototype.quadraticCurveTo = function(cpX, cpY, toX, toY)
260263
/**
261264
* Calculate the points for a bezier curve.
262265
*
266+
* @method bezierCurveTo
263267
* @param {number} cpX Control point x
264268
* @param {number} cpY Control point y
265269
* @param {number} cpX2 Second Control point x
@@ -270,6 +274,8 @@ PIXI.Graphics.prototype.quadraticCurveTo = function(cpX, cpY, toX, toY)
270274
*/
271275
PIXI.Graphics.prototype.bezierCurveTo = function(cpX, cpY, cpX2, cpY2, toX, toY)
272276
{
277+
if( this.currentPath.points.length === 0)this.moveTo(0,0);
278+
273279
var n = 20,
274280
dt,
275281
dt2,
@@ -305,17 +311,24 @@ PIXI.Graphics.prototype.bezierCurveTo = function(cpX, cpY, cpX2, cpY2, toX, toY)
305311
};
306312

307313
/*
308-
* arcTo()
309-
*
314+
* the arcTo() method creates an arc/curve between two tangents on the canvas.
315+
*
310316
* "borrowed" from https://code.google.com/p/fxcanvas/ - thanks google!
317+
*
318+
* @method arcTo
319+
* @param {number} x1 The x-coordinate of the beginning of the arc
320+
* @param {number} y1 The y-coordinate of the beginning of the arc
321+
* @param {number} x2 The x-coordinate of the end of the arc
322+
* @param {number} y2 The y-coordinate of the end of the arc
323+
* @param {number} radius The radius of the arc
324+
* @return {PIXI.Graphics}
311325
*/
312326
PIXI.Graphics.prototype.arcTo = function(x1, y1, x2, y2, radius)
313327
{
314328
// check that path contains subpaths
315-
//if (path.commands.length == 0)
316-
// moveTo(x1, y1);
329+
if( this.currentPath.points.length === 0)this.moveTo(x1, y1);
330+
317331
var points = this.currentPath.points;
318-
319332
var fromX = points[points.length-2];
320333
var fromY = points[points.length-1];
321334

@@ -358,24 +371,30 @@ PIXI.Graphics.prototype.arcTo = function(x1, y1, x2, y2, radius)
358371
return this;
359372
};
360373

361-
/*
362-
* Arc init! TODO add docs
374+
/**
375+
* The arc() method creates an arc/curve (used to create circles, or parts of circles).
376+
*
377+
* @method arc
378+
* @param {number} cx The x-coordinate of the center of the circle
379+
* @param {number} cy The y-coordinate of the center of the circle
380+
* @param {number} radius The radius of the circle
381+
* @param {number} startAngle The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle)
382+
* @param {number} endAngle The ending angle, in radians
383+
* @param {number} anticlockwise Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise.
384+
* @return {PIXI.Graphics}
363385
*/
364386
PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, anticlockwise)
365387
{
366388
var startX = cx + Math.cos(startAngle) * radius;
367389
var startY = cy + Math.sin(startAngle) * radius;
368-
369-
// check that path contains subpaths
370-
// if (path.commands.length == 0)
371-
// this.moveTo(startX, startY);
372-
// else
373-
var points = this.currentPath.points;
374390

375-
var fromX = points[points.length-2];
376-
var fromY = points[points.length-1];
391+
var points = this.currentPath.points;
377392

378-
if(fromX !== startX || fromY !== startY) points.push(startX, startY);
393+
if(points.length !== 0 && points[points.length-2] !== startX || points[points.length-1] !== startY)
394+
{
395+
this.moveTo(startX, startY);
396+
points = this.currentPath.points;
397+
}
379398

380399
if (startAngle === endAngle)return this;
381400

@@ -399,12 +418,15 @@ PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, ant
399418
var cTheta = Math.cos(theta);
400419
var sTheta = Math.sin(theta);
401420

402-
var remainder = ( segs % 1 ) / segs;
421+
var segMinus = segs - 1;
403422

404-
for(var i=0; i<=segs; i++)
423+
var remainder = ( segMinus % 1 ) / segMinus;
424+
425+
for(var i=0; i<=segMinus; i++)
405426
{
406427
var real = i + remainder * i;
407428

429+
408430
var angle = ((theta) + startAngle + (theta2 * real));
409431

410432
var c = Math.cos(angle);

src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ PIXI.WebGLFastSpriteBatch.prototype.flush = function()
269269

270270
if(!this.currentBaseTexture._glTextures[gl.id])PIXI.createWebGLTexture(this.currentBaseTexture, gl);
271271

272-
gl.bindTexture(gl.TEXTURE_2D, this.currentBaseTexture._glTextures[gl.id]);// || PIXI.createWebGLTexture(this.currentBaseTexture, gl));
272+
gl.bindTexture(gl.TEXTURE_2D, this.currentBaseTexture._glTextures[gl.id]);
273273

274274
// upload the verts to the buffer
275275

0 commit comments

Comments
 (0)