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.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;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ PIXI.Texture = function(baseTexture, frame)
|
|||
}
|
||||
|
||||
this.trim = new PIXI.Point();
|
||||
|
||||
if(baseTexture instanceof PIXI.Texture)
|
||||
baseTexture = baseTexture.baseTexture;
|
||||
|
||||
/**
|
||||
* The base texture of this texture
|
||||
|
@ -109,24 +112,9 @@ PIXI.Texture.fromImage = function(imageUrl, crossorigin)
|
|||
|
||||
if(!texture)
|
||||
{
|
||||
var baseTexture = PIXI.BaseTextureCache[imageUrl];
|
||||
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);
|
||||
|
||||
texture = new PIXI.Texture(PIXI.BaseTexture.fromImage(imageUrl, crossorigin));
|
||||
|
||||
PIXI.TextureCache[imageUrl] = texture;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return texture;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue