Fixed graphics bug + updated docs
Fixed issue with getBounds being incorrect for graphics Updated docs Linted code
This commit is contained in:
parent
53506da65e
commit
7713731ab3
145 changed files with 15583 additions and 24078 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.3.0</em>
|
||||
<em>API Docs for: 1.4.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
@ -45,6 +45,8 @@
|
|||
|
||||
<li><a href="../classes/AssetLoader.html">AssetLoader</a></li>
|
||||
|
||||
<li><a href="../classes/AtlasLoader.html">AtlasLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BaseTexture.html">BaseTexture</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
|
||||
|
@ -61,7 +63,7 @@
|
|||
|
||||
<li><a href="../classes/ColorMatrixFilter.html">ColorMatrixFilter</a></li>
|
||||
|
||||
<li><a href="../classes/CustomRenderable.html">CustomRenderable</a></li>
|
||||
<li><a href="../classes/ColorStepFilter.html">ColorStepFilter</a></li>
|
||||
|
||||
<li><a href="../classes/DisplacementFilter.html">DisplacementFilter</a></li>
|
||||
|
||||
|
@ -75,7 +77,7 @@
|
|||
|
||||
<li><a href="../classes/Graphics.html">Graphics</a></li>
|
||||
|
||||
<li><a href="../classes/GreyFilter.html">GreyFilter</a></li>
|
||||
<li><a href="../classes/GrayFilter.html">GrayFilter</a></li>
|
||||
|
||||
<li><a href="../classes/ImageLoader.html">ImageLoader</a></li>
|
||||
|
||||
|
@ -87,6 +89,8 @@
|
|||
|
||||
<li><a href="../classes/PixelateFilter.html">PixelateFilter</a></li>
|
||||
|
||||
<li><a href="../classes/PIXI.PixiShader.html">PIXI.PixiShader</a></li>
|
||||
|
||||
<li><a href="../classes/Point.html">Point</a></li>
|
||||
|
||||
<li><a href="../classes/Polygon.html">Polygon</a></li>
|
||||
|
@ -109,10 +113,10 @@
|
|||
|
||||
<li><a href="../classes/Spine.html">Spine</a></li>
|
||||
|
||||
<li><a href="../classes/Sprite.html">Sprite</a></li>
|
||||
|
||||
<li><a href="../classes/SpriteSheetLoader.html">SpriteSheetLoader</a></li>
|
||||
|
||||
<li><a href="../classes/Sprite™.html">Sprite™</a></li>
|
||||
|
||||
<li><a href="../classes/Stage.html">Stage</a></li>
|
||||
|
||||
<li><a href="../classes/Text.html">Text</a></li>
|
||||
|
@ -121,8 +125,6 @@
|
|||
|
||||
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLBatch.html">WebGLBatch</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
|
||||
|
||||
</ul>
|
||||
|
@ -189,56 +191,55 @@ PIXI.FrameCache = {};
|
|||
*/
|
||||
PIXI.Texture = function(baseTexture, frame)
|
||||
{
|
||||
PIXI.EventTarget.call( this );
|
||||
PIXI.EventTarget.call( this );
|
||||
|
||||
if(!frame)
|
||||
{
|
||||
this.noFrame = true;
|
||||
frame = new PIXI.Rectangle(0,0,1,1);
|
||||
}
|
||||
if(!frame)
|
||||
{
|
||||
this.noFrame = true;
|
||||
frame = new PIXI.Rectangle(0,0,1,1);
|
||||
}
|
||||
|
||||
if(baseTexture instanceof PIXI.Texture)
|
||||
baseTexture = baseTexture.baseTexture;
|
||||
if(baseTexture instanceof PIXI.Texture)
|
||||
baseTexture = baseTexture.baseTexture;
|
||||
|
||||
/**
|
||||
* The base texture of this texture
|
||||
*
|
||||
* @property baseTexture
|
||||
* @type BaseTexture
|
||||
*/
|
||||
this.baseTexture = baseTexture;
|
||||
/**
|
||||
* The base texture of this texture
|
||||
*
|
||||
* @property baseTexture
|
||||
* @type BaseTexture
|
||||
*/
|
||||
this.baseTexture = baseTexture;
|
||||
|
||||
/**
|
||||
* The frame specifies the region of the base texture that this texture uses
|
||||
*
|
||||
* @property frame
|
||||
* @type Rectangle
|
||||
*/
|
||||
this.frame = frame;
|
||||
/**
|
||||
* The frame specifies the region of the base texture that this texture uses
|
||||
*
|
||||
* @property frame
|
||||
* @type Rectangle
|
||||
*/
|
||||
this.frame = frame;
|
||||
|
||||
/**
|
||||
* The trim point
|
||||
*
|
||||
* @property trim
|
||||
* @type Point
|
||||
*/
|
||||
this.trim = new PIXI.Point();
|
||||
/**
|
||||
* The trim point
|
||||
*
|
||||
* @property trim
|
||||
* @type Point
|
||||
*/
|
||||
this.trim = new PIXI.Point();
|
||||
|
||||
this.scope = this;
|
||||
this.scope = this;
|
||||
|
||||
if(baseTexture.hasLoaded)
|
||||
{
|
||||
if(this.noFrame)frame = new PIXI.Rectangle(0,0, baseTexture.width, baseTexture.height);
|
||||
//console.log(frame)
|
||||
|
||||
this.setFrame(frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
var scope = this;
|
||||
baseTexture.addEventListener( 'loaded', function(){ scope.onBaseTextureLoaded()} );
|
||||
}
|
||||
}
|
||||
if(baseTexture.hasLoaded)
|
||||
{
|
||||
if(this.noFrame)frame = new PIXI.Rectangle(0,0, baseTexture.width, baseTexture.height);
|
||||
|
||||
this.setFrame(frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
var scope = this;
|
||||
baseTexture.addEventListener('loaded', function(){ scope.onBaseTextureLoaded(); });
|
||||
}
|
||||
};
|
||||
|
||||
PIXI.Texture.prototype.constructor = PIXI.Texture;
|
||||
|
||||
|
@ -249,18 +250,17 @@ PIXI.Texture.prototype.constructor = PIXI.Texture;
|
|||
* @param event
|
||||
* @private
|
||||
*/
|
||||
PIXI.Texture.prototype.onBaseTextureLoaded = function(event)
|
||||
PIXI.Texture.prototype.onBaseTextureLoaded = function()
|
||||
{
|
||||
var baseTexture = this.baseTexture;
|
||||
baseTexture.removeEventListener( 'loaded', this.onLoaded );
|
||||
var baseTexture = this.baseTexture;
|
||||
baseTexture.removeEventListener( 'loaded', this.onLoaded );
|
||||
|
||||
if(this.noFrame)this.frame = new PIXI.Rectangle(0,0, baseTexture.width, baseTexture.height);
|
||||
this.noFrame = false;
|
||||
this.width = this.frame.width;
|
||||
this.height = this.frame.height;
|
||||
if(this.noFrame)this.frame = new PIXI.Rectangle(0,0, baseTexture.width, baseTexture.height);
|
||||
|
||||
this.setFrame(this.frame);
|
||||
|
||||
this.scope.dispatchEvent( { type: 'update', content: this } );
|
||||
}
|
||||
this.scope.dispatchEvent( { type: 'update', content: this } );
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroys this texture
|
||||
|
@ -270,8 +270,8 @@ PIXI.Texture.prototype.onBaseTextureLoaded = function(event)
|
|||
*/
|
||||
PIXI.Texture.prototype.destroy = function(destroyBase)
|
||||
{
|
||||
if(destroyBase)this.baseTexture.destroy();
|
||||
}
|
||||
if(destroyBase) this.baseTexture.destroy();
|
||||
};
|
||||
|
||||
/**
|
||||
* Specifies the rectangle region of the baseTexture
|
||||
|
@ -281,20 +281,41 @@ PIXI.Texture.prototype.destroy = function(destroyBase)
|
|||
*/
|
||||
PIXI.Texture.prototype.setFrame = function(frame)
|
||||
{
|
||||
this.frame = frame;
|
||||
this.width = frame.width;
|
||||
this.height = frame.height;
|
||||
this.frame = frame;
|
||||
this.width = frame.width;
|
||||
this.height = frame.height;
|
||||
|
||||
if(frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height)
|
||||
{
|
||||
throw new Error("Texture Error: frame does not fit inside the base Texture dimensions " + this);
|
||||
}
|
||||
if(frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height)
|
||||
{
|
||||
throw new Error('Texture Error: frame does not fit inside the base Texture dimensions ' + this);
|
||||
}
|
||||
|
||||
this.updateFrame = true;
|
||||
this.updateFrame = true;
|
||||
|
||||
PIXI.Texture.frameUpdates.push(this);
|
||||
//this.dispatchEvent( { type: 'update', content: this } );
|
||||
}
|
||||
PIXI.Texture.frameUpdates.push(this);
|
||||
//this.dispatchEvent( { type: 'update', content: this } );
|
||||
};
|
||||
|
||||
PIXI.Texture.prototype._updateWebGLuvs = function()
|
||||
{
|
||||
if(!this._uvs)this._uvs = new Float32Array(8);
|
||||
|
||||
var frame = this.frame;
|
||||
var tw = this.baseTexture.width;
|
||||
var th = this.baseTexture.height;
|
||||
|
||||
this._uvs[0] = frame.x / tw;
|
||||
this._uvs[1] = frame.y / th;
|
||||
|
||||
this._uvs[2] = (frame.x + frame.width) / tw;
|
||||
this._uvs[3] = frame.y / th;
|
||||
|
||||
this._uvs[4] = (frame.x + frame.width) / tw;
|
||||
this._uvs[5] = (frame.y + frame.height) / th;
|
||||
|
||||
this._uvs[6] = frame.x / tw;
|
||||
this._uvs[7] = (frame.y + frame.height) / th;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function that returns a texture based on an image url
|
||||
|
@ -306,18 +327,18 @@ PIXI.Texture.prototype.setFrame = function(frame)
|
|||
* @param crossorigin {Boolean} Whether requests should be treated as crossorigin
|
||||
* @return Texture
|
||||
*/
|
||||
PIXI.Texture.fromImage = function(imageUrl, crossorigin)
|
||||
PIXI.Texture.fromImage = function(imageUrl, crossorigin, scaleMode)
|
||||
{
|
||||
var texture = PIXI.TextureCache[imageUrl];
|
||||
var texture = PIXI.TextureCache[imageUrl];
|
||||
|
||||
if(!texture)
|
||||
{
|
||||
texture = new PIXI.Texture(PIXI.BaseTexture.fromImage(imageUrl, crossorigin));
|
||||
PIXI.TextureCache[imageUrl] = texture;
|
||||
}
|
||||
if(!texture)
|
||||
{
|
||||
texture = new PIXI.Texture(PIXI.BaseTexture.fromImage(imageUrl, crossorigin, scaleMode));
|
||||
PIXI.TextureCache[imageUrl] = texture;
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
return texture;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function that returns a texture based on a frame id
|
||||
|
@ -330,10 +351,10 @@ PIXI.Texture.fromImage = function(imageUrl, crossorigin)
|
|||
*/
|
||||
PIXI.Texture.fromFrame = function(frameId)
|
||||
{
|
||||
var texture = PIXI.TextureCache[frameId];
|
||||
if(!texture)throw new Error("The frameId '"+ frameId +"' does not exist in the texture cache " + this);
|
||||
return texture;
|
||||
}
|
||||
var texture = PIXI.TextureCache[frameId];
|
||||
if(!texture) throw new Error('The frameId "' + frameId + '" does not exist in the texture cache ' + this);
|
||||
return texture;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function that returns a texture based on a canvas element
|
||||
|
@ -344,11 +365,11 @@ PIXI.Texture.fromFrame = function(frameId)
|
|||
* @param canvas {Canvas} The canvas element source of the texture
|
||||
* @return Texture
|
||||
*/
|
||||
PIXI.Texture.fromCanvas = function(canvas)
|
||||
PIXI.Texture.fromCanvas = function(canvas, scaleMode)
|
||||
{
|
||||
var baseTexture = new PIXI.BaseTexture(canvas);
|
||||
return new PIXI.Texture(baseTexture);
|
||||
}
|
||||
var baseTexture = new PIXI.BaseTexture(canvas, scaleMode);
|
||||
return new PIXI.Texture(baseTexture);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
@ -361,8 +382,8 @@ PIXI.Texture.fromCanvas = function(canvas)
|
|||
*/
|
||||
PIXI.Texture.addTextureToCache = function(texture, id)
|
||||
{
|
||||
PIXI.TextureCache[id] = texture;
|
||||
}
|
||||
PIXI.TextureCache[id] = texture;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove a texture from the textureCache.
|
||||
|
@ -374,14 +395,15 @@ PIXI.Texture.addTextureToCache = function(texture, id)
|
|||
*/
|
||||
PIXI.Texture.removeTextureFromCache = function(id)
|
||||
{
|
||||
var texture = PIXI.TextureCache[id]
|
||||
PIXI.TextureCache[id] = null;
|
||||
return texture;
|
||||
}
|
||||
var texture = PIXI.TextureCache[id];
|
||||
PIXI.TextureCache[id] = null;
|
||||
return texture;
|
||||
};
|
||||
|
||||
// this is more for webGL.. it contains updated frames..
|
||||
PIXI.Texture.frameUpdates = [];
|
||||
|
||||
PIXI.Texture.SCALE_MODE = PIXI.BaseTexture.SCALE_MODE;
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue