Constructor
(package) new Texture(graphic, resource)
Creates a new texture.
Parameters:
Name | Type | Description |
---|---|---|
graphic |
rune.display.Graphic | Reference to the object to be associated with the texture. |
resource |
HTMLImageElement | Reference to the bitmap to be used for texture data. |
- Source:
Members
(readonly) data :Object
Texture data. When the texture is unique, the texture data consists of an
HTMLCanvasElement object. When the texture is not unique, the texture data
consists of an Image object that is referenced directly from the resource
library. Non-unique data can never be changed or manipulated during runtime.
Type:
- Object
- Source:
(readonly) height :number
The width of the texture in pixels.
Type:
- number
- Source:
(readonly) unique :boolean
Whether the texture should use its own pixel buffer or use a shared memory
reference to an object in the resource library. Usually textures do not
have to be unique, but it can be useful when you want to draw on, or
otherwise change the texture during running time.
Type:
- boolean
- Source:
(readonly) width :number
The width of the texture in pixels.
Type:
- number
- Source:
Methods
replaceColor(c1, c2) → {undefined}
Replaces one specific color with another. Useful for creating multiple
versions of the same texture data with minor color variations. Note that
this method converts the texture data to be unique. The color change cannot
be performed if the texture data is not unique.
Parameters:
Name | Type | Description |
---|---|---|
c1 |
rune.color.Color24 | Old color. |
c2 |
rune.color.Color24 | New color. |
- Source:
Returns:
- Type
- undefined