Class: GradientTexture
texture/gradient.GradientTexture
Represents a texture with a gradient as it's image.
Hierarchy
โณ
GradientTexture
Constructors
constructor
โข new GradientTexture(type
, dir
, resolution
, ...stops
)
Creates a GradientTexture.
Before use the texture must be refreshed, this is done by calling the refresh()
method on the texture.
Parameters
Name | Type | Description |
---|---|---|
type | GradientType | The type of gradient (linear, radial, etc) |
dir | GradientDirection | The direction fo the gradient |
resolution | number | The quality of the gradient |
...stops | ColorStop [] | The color stops in the gradient |
Overrides
Defined in
src/texture/gradient.ts:52
Properties
color
โข color: Color
Inherited from
Defined in
src/texture/texture.ts:13
direction
โข direction: GradientDirection
= GradientDirection.LEFT_TO_RIGHT
Defined in
src/texture/gradient.ts:37
image
โข image: HTMLImageElement
Inherited from
Defined in
src/texture/texture.ts:15
imagePath
โข imagePath: string
Inherited from
Defined in
src/texture/texture.ts:14
isOld
โข isOld: boolean
= false
Inherited from
Defined in
src/texture/texture.ts:16
resolution
โข resolution: number
= 50
Defined in
src/texture/gradient.ts:35
stops
โข stops: ColorStop
[]
Defined in
src/texture/gradient.ts:34
type
โข type: GradientType
= GradientType.LINEAR
Defined in
src/texture/gradient.ts:36
canvas
โช Static
Private
canvas: HTMLCanvasElement
Defined in
src/texture/gradient.ts:39
ctx
โช Static
Private
ctx: CanvasRenderingContext2D
Defined in
src/texture/gradient.ts:40
Methods
createGradient
โธ createGradient(): Object
Creates the canvas gradient fill for this GradientTexture.
Returns
Object
The created gradient and dimensions of the gradient
Name | Type |
---|---|
gradient | CanvasGradient |
height | number |
width | number |
Defined in
src/texture/gradient.ts:88
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.
Inherited from
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.
Inherited from
Defined in
src/texture/texture.ts:35
refresh
โธ refresh(): Promise
<void
>
Regenerates the gradient image.
Returns
Promise
<void
>
A promise which is resolved when the gradient has been loaded into the texture's image.
Defined in
src/texture/gradient.ts:69
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
Inherited from
Defined in
src/texture/texture.ts:58