new Texture(baseTexture, frame, crop, trim)
A texture stores the information that represents an image or part of an image. It cannot be added to the display list directly. Instead use it as the texture for a PIXI.Sprite. If no frame is provided then the whole image is used.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
baseTexture |
PIXI.BaseTexture | The base texture source to create the texture from |
|
frame |
PIXI.Rectangle | The rectangle frame of the texture to show |
|
crop |
PIXI.Rectangle |
<optional> |
The area of original texture |
trim |
PIXI.Rectangle |
<optional> |
Trimmed texture rectangle |
- Source - pixi/textures/Texture.js, line 10
Members
-
baseTexture :PIXI.BaseTexture
-
The base texture that this texture uses.
- Source - pixi/textures/Texture.js, line 43
-
crop :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)
- Source - pixi/textures/Texture.js, line 108
-
frame :PIXI.Rectangle
-
The frame specifies the region of the base texture that this texture uses
- Source - pixi/textures/Texture.js, line 51
-
height :Number
-
The height of the Texture in pixels.
- Source - pixi/textures/Texture.js, line 100
-
noFrame :Boolean
-
Does this Texture have any frame data assigned to it?
- Source - pixi/textures/Texture.js, line 24
-
requiresUpdate :Boolean
-
This will let a renderer know that a texture has been updated (used mainly for webGL uv updates)
- Source - pixi/textures/Texture.js, line 75
-
trim :PIXI.Rectangle
-
The texture trim data.
- Source - pixi/textures/Texture.js, line 59
-
valid :Boolean
-
This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.
- Source - pixi/textures/Texture.js, line 67
-
width :Number
-
The width of the Texture in pixels.
- Source - pixi/textures/Texture.js, line 92
Methods
-
<static> addTextureToCache(texture, id)
-
Adds a texture to the global PIXI.TextureCache. This cache is shared across the whole PIXI object.
Parameters:
Name Type Description texture
PIXI.Texture The Texture to add to the cache.
id
String The id that the texture will be stored against.
- Source - pixi/textures/Texture.js, line 284
-
<static> fromCanvas(canvas, scaleMode)
-
Helper function that creates a new a Texture based on the given canvas element.
Parameters:
Name Type Description canvas
Canvas The canvas element source of the texture
scaleMode
Number See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
Returns:
Texture
- Source - pixi/textures/Texture.js, line 267
-
<static> fromFrame(frameId)
-
Helper function that returns a Texture objected based on the given frame id. If the frame id is not in the texture cache an error will be thrown.
Parameters:
Name Type Description frameId
String The frame id of the texture
Returns:
Texture
- Source - pixi/textures/Texture.js, line 251
-
<static> fromImage(imageUrl, crossorigin, scaleMode)
-
Helper function that creates a Texture object from the given image url. If the image is not in the texture cache it will be created and loaded.
Parameters:
Name Type Description imageUrl
String The image url of the texture
crossorigin
Boolean Whether requests should be treated as crossorigin
scaleMode
Number See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
Returns:
Texture
- Source - pixi/textures/Texture.js, line 227
-
<static> removeTextureFromCache(id) → {PIXI.Texture}
-
Remove a texture from the global PIXI.TextureCache.
Parameters:
Name Type Description id
String The id of the texture to be removed
Returns:
The texture that was removed
- Source - pixi/textures/Texture.js, line 297
-
destroy(destroyBase)
-
Destroys this texture
Parameters:
Name Type Description destroyBase
Boolean Whether to destroy the base texture as well
- Source - pixi/textures/Texture.js, line 149
-
setFrame(frame)
-
Specifies the region of the baseTexture that this texture will use.
Parameters:
Name Type Description frame
PIXI.Rectangle The frame of the texture to set it to
- Source - pixi/textures/Texture.js, line 162