Texture
Texture
Wrapper around a native texture data
Kind: global class
new Texture (param)
Param | Type | Description |
---|---|---|
param | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | number | HTML media element to create texture from or texture id to wrap. |
.valid ⇒ boolean
Kind: instance property of Texture
Returns: boolean - Whether this texture is valid
.width ⇒ int
Kind: instance property of Texture
Returns: int - width of the texture
.height ⇒ int
Kind: instance property of Texture
Returns: int - height of the texture
.update ()
Update the texture to match the HTML element (e.g. reflect the current frame of a video)
Kind: instance method of Texture
.updateSubImage (x, y, w, h)
Update a subrange on the texture to match the HTML element (e.g. reflect the current frame of a video)
Kind: instance method of Texture
Param | Type | Description |
---|---|---|
x | number | x offset |
y | number | y offset |
w | number | width |
h | number | height |
.destroy ()
Destroy and free the texture’s texture altas space and memory.
It is best practice to set the texture variable to null
after calling
destroy to prevent accidental use of the invalid texture:
Kind: instance method of Texture
0.9.0+
Example