Skip to main content

Class: Texture

texture/texture.Texture

Represents a texture with a color and optionally an image that can be applied to Shapes

Hierarchy

Constructors

constructor

โ€ข new Texture(color?)

Creates a Texture instance with a color.

Parameters

NameTypeDescription
colorColorThe 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

NameTypeDescription
imagePathstringA 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

NameTypeDescription
unitnumberThe texture unit the texture is stored in on the GPU

Returns

void

Defined in

src/texture/texture.ts:58