Class: Texture
texture/texture.Texture
Represents a texture with a color and optionally an image that can be applied to Shapes
Hierarchy
Texture
โณ
TextureAtlas
โณ
GradientTexture
Constructors
constructor
โข new Texture(color?
)
Creates a Texture instance with a color.
Parameters
Name | Type | Description |
---|---|---|
color | Color | The color of the texture |
Defined in
src/texture/texture.ts:25
Properties
color
โข color: Color
Defined in
src/texture/texture.ts:13
image
โข image: HTMLImageElement
Defined in
src/texture/texture.ts:15
imagePath
โข imagePath: string
Defined in
src/texture/texture.ts:14
isOld
โข isOld: boolean
= false
Defined in
src/texture/texture.ts:16
unit
โข Private
unit: number
= -1
Defined in
src/texture/texture.ts:18
Methods
getTextureUnit
โธ getTextureUnit(): number
Gets the texture unit the texture is stored in on the GPU, only applies to texture's which use an image.
Returns
number
The texture unit the texture is stored in on the GPU, -1 if it is not currently loaded.
Defined in
src/texture/texture.ts:67
loadImage
โธ loadImage(imagePath
): Promise
<void
>
Loads an image from a path and stores it in the Texture.
Parameters
Name | Type | Description |
---|---|---|
imagePath | string | A path to an image |
Returns
Promise
<void
>
A promise that resolves once the image has loaded or rejects if there is an error while loading the image.
Defined in
src/texture/texture.ts:35
setTextureUnit
โธ setTextureUnit(unit
): void
Set the texture unit to be read from when rendering the texture.
Should only be used if you know what you are doing.
Parameters
Name | Type | Description |
---|---|---|
unit | number | The texture unit the texture is stored in on the GPU |
Returns
void
Defined in
src/texture/texture.ts:58