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
Parameters:
-
baseTexture
BaseTextureThe base texture source to create the texture from
-
frame
RectangleThe rectangle frame of the texture to show
Item Index
Methods
Methods
_updateWebGLuvs
()
private
Updates the internal WebGL UV cache.
addEventListener
-
type
-
listener
Adds a listener for a specific event
Parameters:
-
type
StringA string representing the event type to listen for.
-
listener
FunctionThe callback function that will be fired when the event occurs
addTextureToCache
-
texture
-
id
Adds a texture to the textureCache.
Parameters:
-
texture
Texture -
id
Stringthe id that the texture will be stored against.
clear
()
Clears the RenderTexture.
destroy
-
destroyBase
Destroys this texture
Parameters:
-
destroyBase
BooleanWhether to destroy the base texture as well
dispatchEvent
-
event
Fires the event, ie pretends that the event has happened
Parameters:
-
event
Eventthe event object
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
onBaseTextureLoaded
-
event
Called when the base texture is loaded
Parameters:
-
event
Object
removeAllEventListeners
-
type
Removes all the listeners that were active for the specified event type
Parameters:
-
type
StringA string representing the event type which will have all its listeners removed
removeEventListener
-
type
-
listener
Removes the specified listener that was assigned to the specified event type
Parameters:
-
type
StringA string representing the event type which will have its listener removed
-
listener
FunctionThe callback function that was be fired when the event occured
removeTextureFromCache
-
id
Remove a texture from the textureCache.
Parameters:
-
id
Stringthe id of the texture to be removed
Returns:
the texture that was removed
renderCanvas
-
displayObject
-
clear
This function will draw the display object to the texture.
Parameters:
-
displayObject
DisplayObjectThe display object to render this texture on
-
clear
BooleanIf true the texture will be cleared before the displayObject is drawn
renderWebGL
-
displayObject
-
clear
This function will draw the display object to the texture.
Parameters:
-
displayObject
DisplayObjectThe display object to render this texture on
-
clear
BooleanIf true the texture will be cleared before the displayObject is drawn
resize
-
width
-
height
-
updateBase
Resize the RenderTexture.
Parameters:
-
width
NumberThe width to resize to.
-
height
NumberThe height to resize to.
-
updateBase
BooleanShould the baseTexture.width and height values be resized as well?
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)
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 render texture
height
Number
The height of the Texture in pixels.
listeners
Object
Holds all the listeners
noFrame
Boolean
Does this Texture have any frame data assigned to it?
scope
Object
The context scope under which events are run.
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.
width
Number
The with of the render texture