@@ -284,8 +284,8 @@ PIXI.Polygon.prototype.constructor = PIXI.Polygon;
284
284
*
285
285
* @class Circle
286
286
* @constructor
287
- * @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle
288
- * @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle
287
+ * @param x {Number} The X coordinate of the center of this circle
288
+ * @param y {Number} The Y coordinate of the center of this circle
289
289
* @param radius {Number} The radius of the circle
290
290
*/
291
291
PIXI . Circle = function ( x , y , radius )
@@ -540,7 +540,8 @@ PIXI.identityMatrix = new PIXI.Matrix();
540
540
*/
541
541
542
542
/**
543
- * The base class for all objects that are rendered on the screen.
543
+ * The base class for all objects that are rendered on the screen.
544
+ * This is an abstract class and should not be used on its own rather it should be extended.
544
545
*
545
546
* @class DisplayObject
546
547
* @constructor
@@ -1035,7 +1036,7 @@ PIXI.DisplayObject.prototype.generateTexture = function(renderer)
1035
1036
var bounds = this . getLocalBounds ( ) ;
1036
1037
1037
1038
var renderTexture = new PIXI . RenderTexture ( bounds . width | 0 , bounds . height | 0 , renderer ) ;
1038
- renderTexture . render ( this ) ;
1039
+ renderTexture . render ( this , new PIXI . Point ( - bounds . x , - bounds . y ) ) ;
1039
1040
1040
1041
return renderTexture ;
1041
1042
} ;
@@ -1079,7 +1080,11 @@ PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession)
1079
1080
this . _filters = null ;
1080
1081
1081
1082
this . _cachedSprite . filters = tempFilters ;
1082
- this . _cachedSprite . texture . render ( this ) ;
1083
+ this . _cachedSprite . texture . render ( this , new PIXI . Point ( - bounds . x , - bounds . y ) ) ;
1084
+
1085
+ this . _cachedSprite . anchor . x = - ( bounds . x / bounds . width ) ;
1086
+ this . _cachedSprite . anchor . y = - ( bounds . y / bounds . height ) ;
1087
+
1083
1088
1084
1089
this . _filters = tempFilters ;
1085
1090
@@ -2449,7 +2454,7 @@ PIXI.Text.prototype.updateText = function()
2449
2454
var width = maxLineWidth + this . style . strokeThickness ;
2450
2455
if ( this . style . dropShadow ) width += this . style . dropShadowDistance ;
2451
2456
2452
- this . canvas . width = width ;
2457
+ this . canvas . width = width + this . context . lineWidth ;
2453
2458
//calculate text height
2454
2459
var lineHeight = this . determineFontHeight ( 'font: ' + this . style . font + ';' ) + this . style . strokeThickness ;
2455
2460
@@ -2642,21 +2647,21 @@ PIXI.Text.prototype.wordWrap = function(text)
2642
2647
{
2643
2648
var wordWidth = this . context . measureText ( words [ j ] ) . width ;
2644
2649
var wordWidthWithSpace = wordWidth + this . context . measureText ( ' ' ) . width ;
2645
- if ( wordWidthWithSpace > spaceLeft )
2650
+ if ( j === 0 || wordWidthWithSpace > spaceLeft )
2646
2651
{
2647
2652
// Skip printing the newline if it's the first word of the line that is
2648
2653
// greater than the word wrap width.
2649
2654
if ( j > 0 )
2650
2655
{
2651
2656
result += '\n' ;
2652
2657
}
2653
- result += words [ j ] + ' ' ;
2658
+ result += words [ j ] ;
2654
2659
spaceLeft = this . style . wordWrapWidth - wordWidth ;
2655
2660
}
2656
2661
else
2657
2662
{
2658
2663
spaceLeft -= wordWidthWithSpace ;
2659
- result += words [ j ] + ' ' ;
2664
+ result += ' ' + words [ j ] ;
2660
2665
}
2661
2666
}
2662
2667
@@ -5385,7 +5390,7 @@ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession)
5385
5390
5386
5391
this . maskStack . push ( maskData ) ;
5387
5392
5388
- gl . colorMask ( false , false , false , true ) ;
5393
+ gl . colorMask ( false , false , false , false ) ;
5389
5394
gl . stencilOp ( gl . KEEP , gl . KEEP , gl . INCR ) ;
5390
5395
5391
5396
PIXI . WebGLGraphics . renderGraphics ( maskData , renderSession ) ;
@@ -6531,11 +6536,11 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock)
6531
6536
6532
6537
var filterArea = filterBlock . _filterArea ; // filterBlock.target.getBounds();///filterBlock.target.filterArea;
6533
6538
6534
- var padidng = filter . padding ;
6535
- filterArea . x -= padidng ;
6536
- filterArea . y -= padidng ;
6537
- filterArea . width += padidng * 2 ;
6538
- filterArea . height += padidng * 2 ;
6539
+ var padding = filter . padding ;
6540
+ filterArea . x -= padding ;
6541
+ filterArea . y -= padding ;
6542
+ filterArea . width += padding * 2 ;
6543
+ filterArea . height += padding * 2 ;
6539
6544
6540
6545
// cap filter to screen size..
6541
6546
if ( filterArea . x < 0 ) filterArea . x = 0 ;
@@ -6907,9 +6912,10 @@ PIXI.WebGLFilterManager.prototype.destroy = function()
6907
6912
* @param gl {WebGLContext} the current WebGL drawing context
6908
6913
* @param width {Number} the horizontal range of the filter
6909
6914
* @param height {Number} the vertical range of the filter
6915
+ * @param scaleMode {Number} Should be one of the PIXI.scaleMode consts
6910
6916
* @private
6911
6917
*/
6912
- PIXI . FilterTexture = function ( gl , width , height )
6918
+ PIXI . FilterTexture = function ( gl , width , height , scaleMode )
6913
6919
{
6914
6920
/**
6915
6921
* @property gl
@@ -6921,16 +6927,23 @@ PIXI.FilterTexture = function(gl, width, height)
6921
6927
this . frameBuffer = gl . createFramebuffer ( ) ;
6922
6928
this . texture = gl . createTexture ( ) ;
6923
6929
6930
+ scaleMode = scaleMode || PIXI . scaleModes . DEFAULT ;
6931
+
6924
6932
gl . bindTexture ( gl . TEXTURE_2D , this . texture ) ;
6925
- gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MAG_FILTER , gl . LINEAR ) ;
6926
- gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MIN_FILTER , gl . LINEAR ) ;
6933
+ gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MAG_FILTER , scaleMode === PIXI . scaleModes . LINEAR ? gl . LINEAR : gl . NEAREST ) ;
6934
+ gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MIN_FILTER , scaleMode === PIXI . scaleModes . LINEAR ? gl . LINEAR : gl . NEAREST ) ;
6927
6935
gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_S , gl . CLAMP_TO_EDGE ) ;
6928
6936
gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_T , gl . CLAMP_TO_EDGE ) ;
6929
6937
gl . bindFramebuffer ( gl . FRAMEBUFFER , this . framebuffer ) ;
6930
6938
6931
6939
gl . bindFramebuffer ( gl . FRAMEBUFFER , this . frameBuffer ) ;
6932
6940
gl . framebufferTexture2D ( gl . FRAMEBUFFER , gl . COLOR_ATTACHMENT0 , gl . TEXTURE_2D , this . texture , 0 ) ;
6933
6941
6942
+ // required for masking a mask??
6943
+ this . renderBuffer = gl . createRenderbuffer ( ) ;
6944
+ gl . bindRenderbuffer ( gl . RENDERBUFFER , this . renderBuffer ) ;
6945
+ gl . framebufferRenderbuffer ( gl . FRAMEBUFFER , gl . DEPTH_STENCIL_ATTACHMENT , gl . RENDERBUFFER , this . renderBuffer ) ;
6946
+
6934
6947
this . resize ( width , height ) ;
6935
6948
} ;
6936
6949
@@ -6966,6 +6979,9 @@ PIXI.FilterTexture.prototype.resize = function(width, height)
6966
6979
gl . bindTexture ( gl . TEXTURE_2D , this . texture ) ;
6967
6980
gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , width , height , 0 , gl . RGBA , gl . UNSIGNED_BYTE , null ) ;
6968
6981
6982
+ // update the stencil buffer width and height
6983
+ gl . bindRenderbuffer ( gl . RENDERBUFFER , this . renderBuffer ) ;
6984
+ gl . renderbufferStorage ( gl . RENDERBUFFER , gl . DEPTH_STENCIL , width , height ) ;
6969
6985
} ;
6970
6986
6971
6987
/**
@@ -8009,7 +8025,7 @@ PIXI.Graphics = function()
8009
8025
/**
8010
8026
* the bounds' padding used for bounds calculation
8011
8027
*
8012
- * @property bounds
8028
+ * @property boundsPadding
8013
8029
* @type Number
8014
8030
*/
8015
8031
this . boundsPadding = 10 ;
@@ -8390,28 +8406,24 @@ PIXI.Graphics.prototype.getBounds = function( matrix )
8390
8406
var x4 = a * w1 + c * h0 + tx ;
8391
8407
var y4 = d * h0 + b * w1 + ty ;
8392
8408
8393
- var maxX = - Infinity ;
8394
- var maxY = - Infinity ;
8409
+ var maxX = x1 ;
8410
+ var maxY = y1 ;
8395
8411
8396
- var minX = Infinity ;
8397
- var minY = Infinity ;
8412
+ var minX = x1 ;
8413
+ var minY = y1 ;
8398
8414
8399
- minX = x1 < minX ? x1 : minX ;
8400
8415
minX = x2 < minX ? x2 : minX ;
8401
8416
minX = x3 < minX ? x3 : minX ;
8402
8417
minX = x4 < minX ? x4 : minX ;
8403
8418
8404
- minY = y1 < minY ? y1 : minY ;
8405
8419
minY = y2 < minY ? y2 : minY ;
8406
8420
minY = y3 < minY ? y3 : minY ;
8407
8421
minY = y4 < minY ? y4 : minY ;
8408
8422
8409
- maxX = x1 > maxX ? x1 : maxX ;
8410
8423
maxX = x2 > maxX ? x2 : maxX ;
8411
8424
maxX = x3 > maxX ? x3 : maxX ;
8412
8425
maxX = x4 > maxX ? x4 : maxX ;
8413
8426
8414
- maxY = y1 > maxY ? y1 : maxY ;
8415
8427
maxY = y2 > maxY ? y2 : maxY ;
8416
8428
maxY = y3 > maxY ? y3 : maxY ;
8417
8429
maxY = y4 > maxY ? y4 : maxY ;
@@ -9101,7 +9113,7 @@ PIXI.BaseTexture = function(source, scaleMode)
9101
9113
9102
9114
if ( ! source ) return ;
9103
9115
9104
- if ( this . source . complete || this . source . getContext )
9116
+ if ( ( this . source . complete || this . source . getContext ) && this . source . width && this . source . height )
9105
9117
{
9106
9118
this . hasLoaded = true ;
9107
9119
this . width = this . source . width ;
@@ -9179,7 +9191,7 @@ PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
9179
9191
{
9180
9192
var baseTexture = PIXI . BaseTextureCache [ imageUrl ] ;
9181
9193
9182
- if ( crossorigin === undefined ) crossorigin = true ;
9194
+ if ( crossorigin === undefined && imageUrl . indexOf ( 'data:' ) === - 1 ) crossorigin = true ;
9183
9195
9184
9196
if ( ! baseTexture )
9185
9197
{
@@ -9508,8 +9520,9 @@ PIXI.TextureUvs = function()
9508
9520
* @constructor
9509
9521
* @param width {Number} The width of the render texture
9510
9522
* @param height {Number} The height of the render texture
9523
+ * @param scaleMode {Number} Should be one of the PIXI.scaleMode consts
9511
9524
*/
9512
- PIXI . RenderTexture = function ( width , height , renderer )
9525
+ PIXI . RenderTexture = function ( width , height , renderer , scaleMode )
9513
9526
{
9514
9527
PIXI . EventTarget . call ( this ) ;
9515
9528
@@ -9547,6 +9560,8 @@ PIXI.RenderTexture = function(width, height, renderer)
9547
9560
this . baseTexture . height = this . height ;
9548
9561
this . baseTexture . _glTextures = [ ] ;
9549
9562
9563
+ this . baseTexture . scaleMode = scaleMode || PIXI . scaleModes . DEFAULT ;
9564
+
9550
9565
this . baseTexture . hasLoaded = true ;
9551
9566
9552
9567
// each render texture can only belong to one renderer at the moment if its webGL
@@ -9556,7 +9571,7 @@ PIXI.RenderTexture = function(width, height, renderer)
9556
9571
{
9557
9572
var gl = this . renderer . gl ;
9558
9573
9559
- this . textureBuffer = new PIXI . FilterTexture ( gl , this . width , this . height ) ;
9574
+ this . textureBuffer = new PIXI . FilterTexture ( gl , this . width , this . height , this . baseTexture . scaleMode ) ;
9560
9575
this . baseTexture . _glTextures [ gl . id ] = this . textureBuffer . texture ;
9561
9576
9562
9577
this . render = this . renderWebGL ;
0 commit comments