Texture Class
A texture stores the information that represents an image or part of an image. It cannot be added to the display list directly. To do this use PIXI.Sprite. If no frame is provided then the whole image is used
Constructor
Texture
-
baseTexture
-
frame
-
[crop]
-
[trim]
Parameters:
-
baseTexture
BaseTextureThe base texture source to create the texture from
-
frame
RectangleThe rectangle frame of the texture to show
-
[crop]
Rectangle optionalThe area of original texture
-
[trim]
Rectangle optionalTrimmed texture rectangle
Item Index
Methods
- _updateWebGLuvs
- addTextureToCache static
- destroy
- emit
- fromCanvas static
- fromFrame static
- fromImage static
- listeners
- mixin
- off
- on
- onBaseTextureLoaded
- once
- removeAllListeners
- removeTextureFromCache static
- setFrame
Properties
Methods
_updateWebGLuvs
()
private
Updates the internal WebGL UV cache.
addTextureToCache
-
texture
-
id
Adds a texture to the textureCache.
Parameters:
-
texture
Texture -
id
Stringthe id that the texture will be stored against.
destroy
-
destroyBase
Destroys this texture
Parameters:
-
destroyBase
BooleanWhether to destroy the base texture as well
emit
-
eventName
Emit an event to all registered event listeners.
Parameters:
-
eventName
StringThe name of the event.
Returns:
Indication if we've emitted an event.
fromCanvas
-
canvas
-
scaleMode
Helper function that returns a texture based on a canvas element If the canvas is not in the texture cache it will be created and loaded
Parameters:
-
canvas
CanvasThe canvas element source of the texture
-
scaleMode
NumberShould be one of the PIXI.scaleMode consts
Returns:
Texture
fromFrame
-
frameId
Helper function that returns a texture based on a frame id If the frame id is not in the texture cache an error will be thrown
Parameters:
-
frameId
StringThe frame id of the texture
Returns:
Texture
fromImage
-
imageUrl
-
crossorigin
-
scaleMode
Helper function that returns a texture based on an image url If the image is not in the texture cache it will be created and loaded
Parameters:
-
imageUrl
StringThe image url of the texture
-
crossorigin
BooleanWhether requests should be treated as crossorigin
-
scaleMode
NumberShould be one of the PIXI.scaleMode consts
Returns:
Texture
listeners
-
eventName
Return a list of assigned event listeners.
Parameters:
-
eventName
StringThe events that should be listed.
Returns:
An array of listener functions
mixin
-
object
Mixes in the properties of the EventTarget prototype onto another object
Parameters:
-
object
ObjectThe obj to mix into
off
-
eventName
-
callback
Remove event listeners.
Parameters:
-
eventName
StringThe event we want to remove.
-
callback
FunctionThe listener that we need to find.
on
-
eventName
-
callback
Register a new EventListener for the given event.
Parameters:
-
eventName
StringName of the event.
-
callback
Functonfn Callback function.
onBaseTextureLoaded
-
event
Called when the base texture is loaded
Parameters:
-
event
Object
once
-
eventName
-
callback
Add an EventListener that's only called once.
Parameters:
-
eventName
StringName of the event.
-
callback
FunctionCallback function.
removeAllListeners
-
eventName
Remove all listeners or only the listeners for the specified event.
Parameters:
-
eventName
StringThe event you want to remove all listeners for.
removeTextureFromCache
-
id
Remove a texture from the textureCache.
Parameters:
-
id
Stringthe id of the texture to be removed
Returns:
the texture that was removed
setFrame
-
frame
Specifies the region of the baseTexture that this texture will use.
Parameters:
-
frame
RectangleThe frame of the texture to set it to
Properties
_uvs
Object
private
The WebGL UV data cache.
crop
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)
height
Number
The height of the Texture in pixels.
noFrame
Boolean
Does this Texture have any frame data assigned to it?
requiresUpdate
Boolean
This will let a renderer know that a texture has been updated (used mainly for webGL uv updates)
valid
Boolean
This will let the renderer know if the texture is valid. If its not then it cannot be rendered.
width
Number
The width of the Texture in pixels.