commit
eb63e5a0f8
2 changed files with 27 additions and 17 deletions
|
@ -86,7 +86,29 @@ PIXI.BaseTexture = function(source)
|
||||||
|
|
||||||
PIXI.BaseTexture.constructor = PIXI.BaseTexture;
|
PIXI.BaseTexture.constructor = PIXI.BaseTexture;
|
||||||
|
|
||||||
PIXI.BaseTexture.prototype.fromImage = function(imageUrl)
|
/**
|
||||||
|
*
|
||||||
|
* Helper function that returns a base texture based on an image url
|
||||||
|
* If the image is not in the base texture cache it will be created and loaded
|
||||||
|
* @static
|
||||||
|
* @method fromImage
|
||||||
|
* @param imageUrl {String} The image url of the texture
|
||||||
|
* @return BaseTexture
|
||||||
|
*/
|
||||||
|
PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin)
|
||||||
{
|
{
|
||||||
|
var baseTexture = PIXI.BaseTextureCache[imageUrl];
|
||||||
|
if(!baseTexture)
|
||||||
|
{
|
||||||
|
var image = new Image();
|
||||||
|
if (crossorigin)
|
||||||
|
{
|
||||||
|
image.crossOrigin = '';
|
||||||
|
}
|
||||||
|
image.src = imageUrl;
|
||||||
|
baseTexture = new PIXI.BaseTexture(image);
|
||||||
|
PIXI.BaseTextureCache[imageUrl] = baseTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseTexture;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,9 @@ PIXI.Texture = function(baseTexture, frame)
|
||||||
|
|
||||||
this.trim = new PIXI.Point();
|
this.trim = new PIXI.Point();
|
||||||
|
|
||||||
|
if(baseTexture instanceof PIXI.Texture)
|
||||||
|
baseTexture = baseTexture.baseTexture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base texture of this texture
|
* The base texture of this texture
|
||||||
* @property baseTexture
|
* @property baseTexture
|
||||||
|
@ -109,24 +112,9 @@ PIXI.Texture.fromImage = function(imageUrl, crossorigin)
|
||||||
|
|
||||||
if(!texture)
|
if(!texture)
|
||||||
{
|
{
|
||||||
var baseTexture = PIXI.BaseTextureCache[imageUrl];
|
texture = new PIXI.Texture(PIXI.BaseTexture.fromImage(imageUrl, crossorigin));
|
||||||
if(!baseTexture)
|
|
||||||
{
|
|
||||||
var image = new Image();//new Image();
|
|
||||||
if (crossorigin)
|
|
||||||
{
|
|
||||||
image.crossOrigin = '';
|
|
||||||
}
|
|
||||||
image.src = imageUrl;
|
|
||||||
baseTexture = new PIXI.BaseTexture(image);
|
|
||||||
PIXI.BaseTextureCache[imageUrl] = baseTexture;
|
|
||||||
}
|
|
||||||
texture = new PIXI.Texture(baseTexture);
|
|
||||||
|
|
||||||
|
|
||||||
PIXI.TextureCache[imageUrl] = texture;
|
PIXI.TextureCache[imageUrl] = texture;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue