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>
|
||||
|
@ -186,85 +188,99 @@ PIXI.texturesToDestroy = [];
|
|||
* @constructor
|
||||
* @param source {String} the source object (image or canvas)
|
||||
*/
|
||||
PIXI.BaseTexture = function(source)
|
||||
PIXI.BaseTexture = function(source, scaleMode)
|
||||
{
|
||||
PIXI.EventTarget.call( this );
|
||||
PIXI.EventTarget.call( this );
|
||||
|
||||
/**
|
||||
* [read-only] The width of the base texture set when the image has loaded
|
||||
*
|
||||
* @property width
|
||||
* @type Number
|
||||
* @readOnly
|
||||
*/
|
||||
this.width = 100;
|
||||
/**
|
||||
* [read-only] The width of the base texture set when the image has loaded
|
||||
*
|
||||
* @property width
|
||||
* @type Number
|
||||
* @readOnly
|
||||
*/
|
||||
this.width = 100;
|
||||
|
||||
/**
|
||||
* [read-only] The height of the base texture set when the image has loaded
|
||||
*
|
||||
* @property height
|
||||
* @type Number
|
||||
* @readOnly
|
||||
*/
|
||||
this.height = 100;
|
||||
/**
|
||||
* [read-only] The height of the base texture set when the image has loaded
|
||||
*
|
||||
* @property height
|
||||
* @type Number
|
||||
* @readOnly
|
||||
*/
|
||||
this.height = 100;
|
||||
|
||||
/**
|
||||
* [read-only] Describes if the base texture has loaded or not
|
||||
*
|
||||
* @property hasLoaded
|
||||
* @type Boolean
|
||||
* @readOnly
|
||||
*/
|
||||
this.hasLoaded = false;
|
||||
/**
|
||||
* The scale mode to apply when scaling this texture
|
||||
* @property scaleMode
|
||||
* @type PIXI.BaseTexture.SCALE_MODE
|
||||
* @default PIXI.BaseTexture.SCALE_MODE.LINEAR
|
||||
*/
|
||||
this.scaleMode = scaleMode || PIXI.BaseTexture.SCALE_MODE.DEFAULT;
|
||||
|
||||
/**
|
||||
* The source that is loaded to create the texture
|
||||
*
|
||||
* @property source
|
||||
* @type Image
|
||||
*/
|
||||
this.source = source;
|
||||
/**
|
||||
* [read-only] Describes if the base texture has loaded or not
|
||||
*
|
||||
* @property hasLoaded
|
||||
* @type Boolean
|
||||
* @readOnly
|
||||
*/
|
||||
this.hasLoaded = false;
|
||||
|
||||
if(!source)return;
|
||||
/**
|
||||
* The source that is loaded to create the texture
|
||||
*
|
||||
* @property source
|
||||
* @type Image
|
||||
*/
|
||||
this.source = source;
|
||||
|
||||
if(this.source instanceof Image || this.source instanceof HTMLImageElement)
|
||||
{
|
||||
if(this.source.complete)
|
||||
{
|
||||
this.hasLoaded = true;
|
||||
this.width = this.source.width;
|
||||
this.height = this.source.height;
|
||||
if(!source)return;
|
||||
|
||||
PIXI.texturesToUpdate.push(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.source instanceof Image || this.source instanceof HTMLImageElement)
|
||||
{
|
||||
if(this.source.complete)
|
||||
{
|
||||
this.hasLoaded = true;
|
||||
this.width = this.source.width;
|
||||
this.height = this.source.height;
|
||||
|
||||
var scope = this;
|
||||
this.source.onload = function(){
|
||||
PIXI.texturesToUpdate.push(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
scope.hasLoaded = true;
|
||||
scope.width = scope.source.width;
|
||||
scope.height = scope.source.height;
|
||||
var scope = this;
|
||||
this.source.onload = function() {
|
||||
|
||||
// add it to somewhere...
|
||||
PIXI.texturesToUpdate.push(scope);
|
||||
scope.dispatchEvent( { type: 'loaded', content: scope } );
|
||||
}
|
||||
// this.image.src = imageUrl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hasLoaded = true;
|
||||
this.width = this.source.width;
|
||||
this.height = this.source.height;
|
||||
scope.hasLoaded = true;
|
||||
scope.width = scope.source.width;
|
||||
scope.height = scope.source.height;
|
||||
|
||||
PIXI.texturesToUpdate.push(this);
|
||||
}
|
||||
// add it to somewhere...
|
||||
PIXI.texturesToUpdate.push(scope);
|
||||
scope.dispatchEvent( { type: 'loaded', content: scope } );
|
||||
};
|
||||
//this.image.src = imageUrl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hasLoaded = true;
|
||||
this.width = this.source.width;
|
||||
this.height = this.source.height;
|
||||
|
||||
this._powerOf2 = false;
|
||||
}
|
||||
PIXI.texturesToUpdate.push(this);
|
||||
}
|
||||
|
||||
this.imageUrl = null;
|
||||
this._powerOf2 = false;
|
||||
|
||||
|
||||
// used for webGL
|
||||
this._glTextures = [];
|
||||
|
||||
};
|
||||
|
||||
PIXI.BaseTexture.prototype.constructor = PIXI.BaseTexture;
|
||||
|
||||
|
@ -275,13 +291,29 @@ PIXI.BaseTexture.prototype.constructor = PIXI.BaseTexture;
|
|||
*/
|
||||
PIXI.BaseTexture.prototype.destroy = function()
|
||||
{
|
||||
if(this.source instanceof Image)
|
||||
{
|
||||
this.source.src = null;
|
||||
}
|
||||
this.source = null;
|
||||
PIXI.texturesToDestroy.push(this);
|
||||
}
|
||||
if(this.source instanceof Image)
|
||||
{
|
||||
if (this.imageUrl in PIXI.BaseTextureCache)
|
||||
delete PIXI.BaseTextureCache[this.imageUrl];
|
||||
this.imageUrl = null;
|
||||
this.source.src = null;
|
||||
}
|
||||
this.source = null;
|
||||
PIXI.texturesToDestroy.push(this);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @method destroy
|
||||
*/
|
||||
|
||||
PIXI.BaseTexture.prototype.updateSourceImage = function(newSrc)
|
||||
{
|
||||
this.hasLoaded = false;
|
||||
this.source.src = null;
|
||||
this.source.src = newSrc;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function that returns a base texture based on an image url
|
||||
|
@ -292,26 +324,32 @@ PIXI.BaseTexture.prototype.destroy = function()
|
|||
* @param imageUrl {String} The image url of the texture
|
||||
* @return BaseTexture
|
||||
*/
|
||||
PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin)
|
||||
PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
|
||||
{
|
||||
var baseTexture = PIXI.BaseTextureCache[imageUrl];
|
||||
if(!baseTexture)
|
||||
{
|
||||
// new Image() breaks tex loading in some versions of Chrome.
|
||||
// See https://code.google.com/p/chromium/issues/detail?id=238071
|
||||
var image = new Image();//document.createElement('img');
|
||||
if (crossorigin)
|
||||
{
|
||||
image.crossOrigin = '';
|
||||
}
|
||||
image.src = imageUrl;
|
||||
baseTexture = new PIXI.BaseTexture(image);
|
||||
PIXI.BaseTextureCache[imageUrl] = baseTexture;
|
||||
}
|
||||
var baseTexture = PIXI.BaseTextureCache[imageUrl];
|
||||
if(!baseTexture)
|
||||
{
|
||||
// new Image() breaks tex loading in some versions of Chrome.
|
||||
// See https://code.google.com/p/chromium/issues/detail?id=238071
|
||||
var image = new Image();//document.createElement('img');
|
||||
if (crossorigin)
|
||||
{
|
||||
image.crossOrigin = '';
|
||||
}
|
||||
image.src = imageUrl;
|
||||
baseTexture = new PIXI.BaseTexture(image, scaleMode);
|
||||
baseTexture.imageUrl = imageUrl;
|
||||
PIXI.BaseTextureCache[imageUrl] = baseTexture;
|
||||
}
|
||||
|
||||
return baseTexture;
|
||||
}
|
||||
return baseTexture;
|
||||
};
|
||||
|
||||
PIXI.BaseTexture.SCALE_MODE = {
|
||||
DEFAULT: 0, //default to LINEAR
|
||||
LINEAR: 0,
|
||||
NEAREST: 1
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue