Name | Type | Attributes | Description |
---|---|---|---|
baseTexture |
PIXI.BaseTexture<R> |
The base texture source to create the texture from |
|
frame |
PIXI.Rectangle |
<optional> |
The rectangle frame of the texture to show |
orig |
PIXI.Rectangle |
<optional> |
The area of original texture |
trim |
PIXI.Rectangle |
<optional> |
Trimmed rectangle of original texture |
rotate |
number |
<optional> |
indicates how the texture was rotated by texture packer. See PIXI.groupD8 |
anchor |
IPointData |
<optional> |
Default anchor point used for sprite placement / rotation |
borders |
PIXI.ITextureBorders |
<optional> |
Default borders used for 9-slice scaling. See PIXI.NineSlicePlane |
Extends
- EventEmitter
Members
PIXI.Texture.EMPTY PIXI.Texture<PIXI.Resource> static
An empty texture, used often to not have to create multiple empty textures. Can not be destroyed.
PIXI.Texture.WHITE PIXI.Texture<PIXI.CanvasResource> static
A white texture of 16x16 size, used for graphics and other things Can not be destroyed.
_frame PIXI.Rectangle
This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)
baseTexture PIXI.BaseTexture<R>
The base texture that this texture uses.
defaultAnchor PIXI.Point
Anchor point that is used as default if sprite is created with this texture.
Changing the defaultAnchor
at a later point of time will not update Sprite's anchor point.
- Default Value:
- {0,0}
defaultBorders PIXI.ITextureBorders
Default width of the non-scalable border that is used if 9-slice plane is created with this texture.
- Since:
- 7.2.0
- See:
Has the texture been destroyed?
frame PIXI.Rectangle
The frame specifies the region of the base texture that this texture uses.
Please call updateUvs()
after you change coordinates of frame
manually.
The height of the Texture in pixels.
Does this Texture have any frame data assigned to it?
This mode is enabled automatically if no frame was passed inside constructor.
In this mode texture is subscribed to baseTexture events, and fires update
on any change.
Beware, after loading or resize of baseTexture event can fired two times! If you want more control, subscribe on baseTexture itself.
Any assignment of frame
switches off noFrame
mode.
Example
texture.on('update', () => {});
orig PIXI.Rectangle
This is the area of original texture, before it was put in atlas.
Returns resolution of baseTexture
Indicates whether the texture is rotated inside the atlas set to 2 to compensate for texture packer rotation set to 6 to compensate for spine packer rotation can be used to rotate or mirror sprites See PIXI.groupD8 for explanation
The ids under which this Texture has been added to the texture cache. This is automatically set as long as Texture.addToCache is used, but may not be set if a Texture is added directly to the TextureCache array.
trim PIXI.Rectangle
This is the trimmed area of original texture, before it was put in atlas
Please call updateUvs()
after you change coordinates of trim
manually.
uvMatrix PIXI.TextureMatrix
Default TextureMatrix instance for this texture. By default, that object is not created because its heavy.
This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.
The width of the Texture in pixels.
Update ID is observed by sprites and TextureMatrix instances. Call updateUvs() to increment it.
_uvs PIXI.TextureUvs protected
The WebGL UV data cache. Can be used as quad UV.
Methods
Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object.
Name | Type | Description |
---|---|---|
texture |
PIXI.Texture |
The Texture to add to the cache. |
id |
string |
The id that the Texture will be stored against. |
PIXI.Texture.from (source, options, strict) PIXI.Texture static
Helper function that creates a new Texture based on the source you provide. The source can be - frame id, image url, video url, canvas element, video element, base texture
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
string | PIXI.BaseTexture | HTMLImageElement | HTMLVideoElement | ImageBitmap | PIXI.ICanvas |
Source or array of sources to create texture from |
||
options |
IBaseTextureOptions<RO> |
See PIXI.BaseTexture's constructor for options. |
||
options.pixiIdPrefix |
string |
<optional> |
pixiid |
If a source has no id, this is the prefix of the generated id |
strict |
boolean |
<optional> |
Enforce strict-mode, see PIXI.settings.STRICT_TEXTURE_CACHE. |
Returns:
Type | Description |
---|---|
PIXI.Texture | The newly created texture |
PIXI.Texture.fromBuffer (buffer, width, height, options) PIXI.Texture<PIXI.BufferResource> static
Create a new Texture with a BufferResource from a typed array.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
buffer |
BufferType |
The optional array to use. If no data is provided, a new Float32Array is created. |
||
width |
number |
Width of the resource |
||
height |
number |
Height of the resource |
||
options |
IBaseTextureOptions<PIXI.IBufferResourceOptions> |
<optional> |
See PIXI.BaseTexture's constructor for options. Default properties are different from the constructor's defaults. |
|
options.format |
PIXI.FORMATS |
<optional> |
The format is not given, the type is inferred from the
type of the buffer: |
|
options.type |
PIXI.TYPES |
<optional> |
The type is not given, the type is inferred from the
type of the buffer. Maps Float32Array to |
|
options.alphaMode |
PIXI.ALPHA_MODES |
<optional> |
PIXI.ALPHA_MODES.NPM | |
options.scaleMode |
PIXI.SCALE_MODES |
<optional> |
PIXI.SCALE_MODES.NEAREST |
Returns:
Type | Description |
---|---|
PIXI.Texture<PIXI.BufferResource> |
|
PIXI.Texture.fromLoader (source, imageUrl, name, options) Promise<R<PIXI.Texture>> static
Create a texture from a source and add to the cache.
Name | Type | Attributes | Description |
---|---|---|---|
source |
HTMLImageElement | HTMLVideoElement | ImageBitmap | PIXI.ICanvas | string |
The input source. |
|
imageUrl |
string |
File name of texture, for cache and resolving resolution. |
|
name |
string |
<optional> |
Human readable name for the texture cache. If no name is
specified, only |
options |
IBaseTextureOptions |
<optional> |
Returns:
Type | Description |
---|---|
Promise<R<PIXI.Texture>> |
|
PIXI.Texture.fromURL (url, options) Promise<R<PIXI.Texture>> static
Useful for loading textures via URLs. Use instead of Texture.from
because
it does a better job of handling failed URLs more effectively. This also ignores
PIXI.settings.STRICT_TEXTURE_CACHE
. Works for Videos, SVGs, Images.
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | string[] |
The remote URL or array of URLs to load. |
|
options |
IBaseTextureOptions<RO> |
<optional> |
Optional options to include |
Returns:
Type | Description |
---|---|
Promise<R<PIXI.Texture>> |
|
PIXI.Texture.removeFromCache (texture) PIXI.Texture | null static
Remove a Texture from the global TextureCache.
Name | Type | Description |
---|---|---|
texture |
string | PIXI.Texture |
id of a Texture to be removed, or a Texture instance itself |
Returns:
Type | Description |
---|---|
PIXI.Texture | null |
|
castToBaseTexture () PIXI.BaseTexture
Utility function for BaseTexture|Texture cast.
Returns:
Type | Description |
---|---|
PIXI.BaseTexture |
clone () PIXI.Texture
Creates a new texture object that acts the same as this one.
Returns:
Type | Description |
---|---|
PIXI.Texture |
|
Destroys this texture
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
destroyBase |
boolean |
<optional> |
false |
Whether to destroy the base texture as well |
Fires:
Updates this texture on the gpu.
Calls the TextureResource update.
If you adjusted frame
manually, please call updateUvs()
instead.
Updates the internal WebGL UV cache. Use it after you change frame
or trim
of the texture.
Call it after changing the frame
Called when the base texture is updated
Name | Type | Description |
---|---|---|
baseTexture |
PIXI.BaseTexture |
The base texture. |