@pixi/sprite
Advanced tools
Comparing version 5.0.0-alpha.2 to 5.0.0-alpha.3
/*! | ||
* @pixi/sprite - v5.0.0-alpha.2 | ||
* Compiled Sat, 17 Mar 2018 17:48:48 UTC | ||
* @pixi/sprite - v5.0.0-alpha.3 | ||
* Compiled Tue, 03 Jul 2018 04:08:21 UTC | ||
* | ||
@@ -9,4 +9,4 @@ * @pixi/sprite is licensed under the MIT License. | ||
import { ObservablePoint, Point, Rectangle } from '@pixi/math'; | ||
import { TextureCache, createIndicesForQuads, premultiplyBlendMode, premultiplyTint, sign } from '@pixi/utils'; | ||
import { Buffer, Geometry, ObjectRenderer, Shader, Texture, UniformGroup, checkMaxIfStatmentsInShader } from '@pixi/core'; | ||
import { createIndicesForQuads, premultiplyBlendMode, premultiplyTint, sign } from '@pixi/utils'; | ||
import { Buffer, Geometry, ObjectRenderer, Shader, Texture, UniformGroup, checkMaxIfStatementsInShader } from '@pixi/core'; | ||
import { BLEND_MODES, ENV } from '@pixi/constants'; | ||
@@ -25,3 +25,3 @@ import { Container } from '@pixi/display'; | ||
* ```js | ||
* let sprite = new PIXI.Sprite.fromImage('assets/image.png'); | ||
* let sprite = new PIXI.Sprite.from('assets/image.png'); | ||
* ``` | ||
@@ -426,2 +426,4 @@ * | ||
this._texture.off('update', this._onTextureUpdate, this); | ||
this._anchor = null; | ||
@@ -449,27 +451,12 @@ | ||
* @static | ||
* @param {number|string|PIXI.BaseTexture|HTMLCanvasElement|HTMLVideoElement} source Source to create texture from | ||
* @param {number|string|PIXI.Texture|HTMLCanvasElement|HTMLVideoElement} source Source to create texture from | ||
* @param {object} [options] See {@link PIXI.BaseTexture}'s constructor for options. | ||
* @return {PIXI.Sprite} The newly created sprite | ||
*/ | ||
Sprite.from = function from (source) | ||
Sprite.from = function from (source, options) | ||
{ | ||
return new Sprite(Texture.from(source)); | ||
}; | ||
var texture = (source instanceof Texture) | ||
? source | ||
: new Texture.from(source, options); | ||
/** | ||
* Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId | ||
* The frame ids are created when a Texture packer file has been loaded | ||
* | ||
* @static | ||
* @param {string} frameId - The frame Id of the texture in the cache | ||
* @return {PIXI.Sprite} A new Sprite using a texture from the texture cache matching the frameId | ||
*/ | ||
Sprite.fromFrame = function fromFrame (frameId) | ||
{ | ||
var texture = TextureCache[frameId]; | ||
if (!texture) | ||
{ | ||
throw new Error(("The frameId \"" + frameId + "\" does not exist in the texture cache")); | ||
} | ||
return new Sprite(texture); | ||
@@ -479,23 +466,2 @@ }; | ||
/** | ||
* Helper function that creates a sprite that will contain a texture based on an image url | ||
* If the image is not in the texture cache it will be loaded | ||
* | ||
* @static | ||
* @param {string} imageId - The image url of the texture | ||
* @param {boolean} [crossorigin=(auto)] - if you want to specify the cross-origin parameter | ||
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - if you want to specify the scale mode, | ||
* see {@link PIXI.SCALE_MODES} for possible values | ||
* @return {PIXI.Sprite} A new Sprite using a texture from the texture cache matching the image id | ||
*/ | ||
Sprite.fromImage = function fromImage (imageId, crossorigin, scaleMode) | ||
{ | ||
return new Sprite(Texture.fromImage(imageId, crossorigin, scaleMode)); | ||
}; | ||
Sprite.fromSVG = function fromSVG (svgId, crossorigin, scaleMode) | ||
{ | ||
return new Sprite(Texture.fromSVG(svgId, crossorigin, scaleMode)); | ||
}; | ||
/** | ||
* The width of the sprite, setting this will actually modify the scale to achieve the value set | ||
@@ -537,7 +503,16 @@ * | ||
/** | ||
* The anchor sets the origin point of the texture. | ||
* The default is 0,0 this means the texture's origin is the top left | ||
* Setting the anchor to 0.5,0.5 means the texture's origin is centered | ||
* Setting the anchor to 1,1 would mean the texture's origin point will be the bottom right corner | ||
* The anchor sets the origin point of the text. | ||
* | ||
* The default is `(0,0)`, this means the text's origin is the top left. | ||
* | ||
* Setting the anchor to `(0.5,0.5)` means the text's origin is centered. | ||
* | ||
* Setting the anchor to `(1,1)` would mean the text's origin point will be the bottom right corner. | ||
* | ||
* If you pass only single parameter, it will set both x and y to the same value as shown in the example below. | ||
* | ||
* @example | ||
* const sprite = new PIXI.Sprite(texture); | ||
* sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5). | ||
* | ||
* @member {PIXI.ObservablePoint} | ||
@@ -590,3 +565,3 @@ */ | ||
this._texture = value; | ||
this._texture = value || Texture.EMPTY; | ||
this.cachedTint = 0xFFFFFF; | ||
@@ -778,3 +753,3 @@ | ||
* The default shaders that is used if a sprite doesn't have a more specific one. | ||
* there is a shader for each number of textures that can be rendererd. | ||
* there is a shader for each number of textures that can be rendered. | ||
* These shaders will also be generated on the fly as required. | ||
@@ -829,3 +804,3 @@ * @member {PIXI.Shader[]} | ||
// step 2: check the maximum number of if statements the shader can have too.. | ||
this.MAX_TEXTURES = checkMaxIfStatmentsInShader(this.MAX_TEXTURES, gl); | ||
this.MAX_TEXTURES = checkMaxIfStatementsInShader(this.MAX_TEXTURES, gl); | ||
} | ||
@@ -941,3 +916,3 @@ | ||
{ | ||
// upload the sprite elemetns... | ||
// upload the sprite elements... | ||
// they have all ready been calculated so we just need to push them into the buffer. | ||
@@ -944,0 +919,0 @@ |
/*! | ||
* @pixi/sprite - v5.0.0-alpha.2 | ||
* Compiled Sat, 17 Mar 2018 17:48:48 UTC | ||
* @pixi/sprite - v5.0.0-alpha.3 | ||
* Compiled Tue, 03 Jul 2018 04:08:21 UTC | ||
* | ||
@@ -30,3 +30,3 @@ * @pixi/sprite is licensed under the MIT License. | ||
* ```js | ||
* let sprite = new PIXI.Sprite.fromImage('assets/image.png'); | ||
* let sprite = new PIXI.Sprite.from('assets/image.png'); | ||
* ``` | ||
@@ -431,2 +431,4 @@ * | ||
this._texture.off('update', this._onTextureUpdate, this); | ||
this._anchor = null; | ||
@@ -454,27 +456,12 @@ | ||
* @static | ||
* @param {number|string|PIXI.BaseTexture|HTMLCanvasElement|HTMLVideoElement} source Source to create texture from | ||
* @param {number|string|PIXI.Texture|HTMLCanvasElement|HTMLVideoElement} source Source to create texture from | ||
* @param {object} [options] See {@link PIXI.BaseTexture}'s constructor for options. | ||
* @return {PIXI.Sprite} The newly created sprite | ||
*/ | ||
Sprite.from = function from (source) | ||
Sprite.from = function from (source, options) | ||
{ | ||
return new Sprite(core.Texture.from(source)); | ||
}; | ||
var texture = (source instanceof core.Texture) | ||
? source | ||
: new core.Texture.from(source, options); | ||
/** | ||
* Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId | ||
* The frame ids are created when a Texture packer file has been loaded | ||
* | ||
* @static | ||
* @param {string} frameId - The frame Id of the texture in the cache | ||
* @return {PIXI.Sprite} A new Sprite using a texture from the texture cache matching the frameId | ||
*/ | ||
Sprite.fromFrame = function fromFrame (frameId) | ||
{ | ||
var texture = utils.TextureCache[frameId]; | ||
if (!texture) | ||
{ | ||
throw new Error(("The frameId \"" + frameId + "\" does not exist in the texture cache")); | ||
} | ||
return new Sprite(texture); | ||
@@ -484,23 +471,2 @@ }; | ||
/** | ||
* Helper function that creates a sprite that will contain a texture based on an image url | ||
* If the image is not in the texture cache it will be loaded | ||
* | ||
* @static | ||
* @param {string} imageId - The image url of the texture | ||
* @param {boolean} [crossorigin=(auto)] - if you want to specify the cross-origin parameter | ||
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - if you want to specify the scale mode, | ||
* see {@link PIXI.SCALE_MODES} for possible values | ||
* @return {PIXI.Sprite} A new Sprite using a texture from the texture cache matching the image id | ||
*/ | ||
Sprite.fromImage = function fromImage (imageId, crossorigin, scaleMode) | ||
{ | ||
return new Sprite(core.Texture.fromImage(imageId, crossorigin, scaleMode)); | ||
}; | ||
Sprite.fromSVG = function fromSVG (svgId, crossorigin, scaleMode) | ||
{ | ||
return new Sprite(core.Texture.fromSVG(svgId, crossorigin, scaleMode)); | ||
}; | ||
/** | ||
* The width of the sprite, setting this will actually modify the scale to achieve the value set | ||
@@ -542,7 +508,16 @@ * | ||
/** | ||
* The anchor sets the origin point of the texture. | ||
* The default is 0,0 this means the texture's origin is the top left | ||
* Setting the anchor to 0.5,0.5 means the texture's origin is centered | ||
* Setting the anchor to 1,1 would mean the texture's origin point will be the bottom right corner | ||
* The anchor sets the origin point of the text. | ||
* | ||
* The default is `(0,0)`, this means the text's origin is the top left. | ||
* | ||
* Setting the anchor to `(0.5,0.5)` means the text's origin is centered. | ||
* | ||
* Setting the anchor to `(1,1)` would mean the text's origin point will be the bottom right corner. | ||
* | ||
* If you pass only single parameter, it will set both x and y to the same value as shown in the example below. | ||
* | ||
* @example | ||
* const sprite = new PIXI.Sprite(texture); | ||
* sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5). | ||
* | ||
* @member {PIXI.ObservablePoint} | ||
@@ -595,3 +570,3 @@ */ | ||
this._texture = value; | ||
this._texture = value || core.Texture.EMPTY; | ||
this.cachedTint = 0xFFFFFF; | ||
@@ -783,3 +758,3 @@ | ||
* The default shaders that is used if a sprite doesn't have a more specific one. | ||
* there is a shader for each number of textures that can be rendererd. | ||
* there is a shader for each number of textures that can be rendered. | ||
* These shaders will also be generated on the fly as required. | ||
@@ -834,3 +809,3 @@ * @member {PIXI.Shader[]} | ||
// step 2: check the maximum number of if statements the shader can have too.. | ||
this.MAX_TEXTURES = core.checkMaxIfStatmentsInShader(this.MAX_TEXTURES, gl); | ||
this.MAX_TEXTURES = core.checkMaxIfStatementsInShader(this.MAX_TEXTURES, gl); | ||
} | ||
@@ -946,3 +921,3 @@ | ||
{ | ||
// upload the sprite elemetns... | ||
// upload the sprite elements... | ||
// they have all ready been calculated so we just need to push them into the buffer. | ||
@@ -949,0 +924,0 @@ |
{ | ||
"name": "@pixi/sprite", | ||
"version": "5.0.0-alpha.2", | ||
"version": "5.0.0-alpha.3", | ||
"main": "lib/sprite.js", | ||
@@ -28,9 +28,9 @@ "module": "lib/sprite.es.js", | ||
"dependencies": { | ||
"@pixi/canvas-renderer": "^5.0.0-alpha.2", | ||
"@pixi/constants": "^5.0.0-alpha.2", | ||
"@pixi/core": "^5.0.0-alpha.2", | ||
"@pixi/display": "^5.0.0-alpha.2", | ||
"@pixi/math": "^5.0.0-alpha.2", | ||
"@pixi/settings": "^5.0.0-alpha.2", | ||
"@pixi/utils": "^5.0.0-alpha.2", | ||
"@pixi/canvas-renderer": "^5.0.0-alpha.3", | ||
"@pixi/constants": "^5.0.0-alpha.3", | ||
"@pixi/core": "^5.0.0-alpha.3", | ||
"@pixi/display": "^5.0.0-alpha.3", | ||
"@pixi/math": "^5.0.0-alpha.3", | ||
"@pixi/settings": "^5.0.0-alpha.3", | ||
"@pixi/utils": "^5.0.0-alpha.3", | ||
"bit-twiddle": "^1.0.2" | ||
@@ -37,0 +37,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
182954
1904