new Texture(baseTexture [, frame] [, crop] [, trim] [, rotate])
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
baseTexture |
BaseTexture | The base texture source to create the texture from |
|
frame |
Rectangle |
<optional> |
The rectangle frame of the texture to show |
crop |
Rectangle |
<optional> |
The area of original texture |
trim |
Rectangle |
<optional> |
Trimmed texture rectangle |
rotate |
number |
<optional> |
indicates how the texture was rotated by texture packer. See GroupD8 |
- Source:
Members
-
<static, constant> EMPTY
-
An empty texture, used often to not have to create multiple empty textures.
- Source:
-
baseTexture :BaseTexture
-
The base texture that this texture uses.
Type:
- Source:
-
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)Type:
- Source:
-
frame :Rectangle
-
The frame specifies the region of the base texture that this texture uses.
Type:
- Source:
-
height :number
-
The height of the Texture in pixels.
Type:
- number
- Source:
-
noFrame :boolean
-
Does this Texture have any frame data assigned to it?
Type:
- boolean
- Source:
-
requiresUpdate :boolean
-
This will let a renderer know that a texture has been updated (used mainly for webGL uv updates)
Type:
- boolean
- Source:
-
rotate :number
-
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 GroupD8 for explanationType:
- number
- Source:
-
trim :Rectangle
-
The texture trim data.
Type:
- Source:
-
valid :boolean
-
This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.
Type:
- boolean
- Source:
-
width :number
-
The width of the Texture in pixels.
Type:
- number
- Source:
Methods
-
<static> addTextureToCache(texture, id)
-
Adds a texture to the global utils.TextureCache. This cache is shared across the whole PIXI object.
Parameters:
Name Type Description texture
Texture The Texture to add to the cache.
id
string The id that the texture will be stored against.
- Source:
-
<static> fromCanvas(canvas, scaleMode)
-
Helper function that creates a new Texture based on the given canvas element.
Parameters:
Name Type Description canvas
Canvas The canvas element source of the texture
scaleMode
number See SCALE_MODES for possible values
- Source:
Returns:
- Type
- Texture
-
<static> fromFrame(frameId)
-
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 loadedParameters:
Name Type Description frameId
string The frame Id of the texture in the cache
- Source:
Returns:
The newly created texture
- Type
- Texture
-
<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 SCALE_MODES for possible values
- Source:
Returns:
The newly created texture
- Type
- Texture
-
<static> fromVideo(video, scaleMode)
-
Helper function that creates a new Texture based on the given video element.
Parameters:
Name Type Description video
HTMLVideoElement scaleMode
number See SCALE_MODES for possible values
- Source:
Returns:
A Texture
- Type
- Texture
-
<static> fromVideoUrl(videoUrl, scaleMode)
-
Helper function that creates a new Texture based on the video url.
Parameters:
Name Type Description videoUrl
string scaleMode
number See SCALE_MODES for possible values
- Source:
Returns:
A Texture
- Type
- Texture
-
<static> removeTextureFromCache(id)
-
Remove a texture from the global utils.TextureCache.
Parameters:
Name Type Description id
string The id of the texture to be removed
- Source:
Returns:
The texture that was removed
- Type
- Texture
Events
-
update
-
Fired when the texture is updated. This happens if the frame or the baseTexture is updated.
- Source: