# Two.Texture
Extends: Two.Element
Fundamental to work with bitmap data, a.k.a. pregenerated imagery, in Two.js. Supported formats include jpg, png, gif, and tiff. See Two.Texture.RegularExpressions for a full list of supported formats.
# Constructor
Argument | Description |
---|---|
src | The URL path to an image file or an <img /> element. |
callback | An optional callback function once the image has been loaded. |
# RegularExpressions
Two.Texture.RegularExpressions
A map of compatible DOM Elements categorized by media format.
# ImageRegistry
Two.Texture.ImageRegistry
A canonical listing of image data used in a single session of Two.js.
# getAbsoluteURL
Two.Texture.getAbsoluteURL
Returns: String
- The serialized absolute path.
Serializes a URL as an absolute path for canonical attribution in Two.ImageRegistry.
Argument | Description |
---|---|
path |
# loadHeadlessBuffer
Two.Texture.loadHeadlessBuffer
Loads an image as a buffer in headless environments.
Argument | Description |
---|---|
texture | The Two.Texture to be loaded. |
loaded | The callback function to be triggered once the image is loaded. |
# getTag
Two.Texture.getTag
Returns: String
- Returns the tag name of an image, video, or canvas node.
Retrieves the tag name of an image, video, or canvas node.
Argument | Description |
---|---|
image | The image to infer the tag name from. |
# getImage
Two.Texture.getImage
Returns: HTMLImageElement
- Returns either a cached version of the image or a new one that is registered in Two.Texture.ImageRegistry.
Convenience function to set Two.Texture.image properties with canonical versions set in Two.Texture.ImageRegistry.
Argument | Description |
---|---|
src | The URL path of the image. |
# Register
Two.Register
A collection of functions to register different types of textures. Used internally by a Two.Texture.
# load
Two.Texture.load
Argument | Description |
---|---|
texture | The texture to load. |
callback | The function to be called once the texture is loaded. |
# FlagOffset
Two.Texture.FlagOffset
Cached method to let renderers know offset
has been updated on a Two.Texture.
# FlagScale
Two.Texture.FlagScale
Cached method to let renderers know scale
has been updated on a Two.Texture.
# repeat
Two.Texture.repeat
CSS style declaration to tile Two.Path. Valid values include: 'no-repeat'
, 'repeat'
, 'repeat-x'
, 'repeat-y'
.
# offset
Two.Texture.offset
A two-component vector describing any pixel offset of the texture when applied to a Two.Path.
# image
Two.Texture.image
The corresponding DOM Element of the texture. Can be a <img />
, <canvas />
, or <video />
element. See Two.Texture.RegularExpressions for a full list of supported elements.
# clone
Two.Texture.clone
Returns: Two.Texture
Create a new instance of Two.Texture with the same properties of the current texture.
# toObject
Two.Texture.toObject
Returns: Object
Return a JSON compatible plain object that represents the texture.