UWAL / Color
Type Aliases
ColorParam
type ColorParam = Color | GPUColor;Type Parameters
| Type Parameter |
|---|
Classes
Color
Utility class to convert, adjust and compare color values.
Constructors
Constructor
new Color(
hexOrRed?,
green?,
blue?,
alpha?): Color;Create a new color instance from a single hex value or using 3 to 4 channel components in [0 - 255] format.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
hexOrRed? | number | 0x000000 | Hex or red channel value |
green? | number | undefined | Green channel value |
blue? | number | undefined | Blue channel value |
alpha? | number | 0xff | Alpha value |
Returns
Methods
Set()
Set(hex, alpha?): Color;Override this color value.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
hex | number | undefined | Hex value |
alpha? | number | 0xff | Alpha value |
Returns
Premultiply()
Premultiply(alpha?, dst?): Color;Multiply this color with an alpha value.
Parameters
| Parameter | Type | Description |
|---|---|---|
alpha? | number | Alpha value to multiply, defaults to this color alpha if not provided |
dst? | Color | Destination color, a new Color instance will be created if not provided |
Returns
Random()
Random(alpha?): Color;Set this color to a random value.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
alpha? | number | 1 | Alpha value to keep. Call with undefined to randomize it |
Returns
Equals()
Equals(color): boolean;Compare this color value with the provided one.
Parameters
| Parameter | Type | Description |
|---|---|---|
color | number | ColorParam | Color to compare |
Returns
boolean
Accessors
rgb
Get Signature
get rgb(): number[];Returns
number[]
This color components in [0 - 1] format. Alpha is omitted.
Set Signature
set rgb(values): void;Set this color components using [0 - 1] format. Alpha defaults to 1 if not provided.
Parameters
| Parameter | Type | Description |
|---|---|---|
values | number[] | 3 to 4 color channels |
Returns
void
a
Get Signature
get a(): number;Returns
number
This color alpha in [0 - 1] format.
Set Signature
set a(value): void;Set this color alpha in [0 - 1] format.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | number | Alpha value |
Returns
void
rgba
Get Signature
get rgba(): number[];Returns
number[]
This color components in [0 - 1] format.
Set Signature
set rgba(values): void;Set this color components using [0 - 1] format.
Alias
Parameters
| Parameter | Type | Description |
|---|---|---|
values | number[] | 3 to 4 color channels |
Returns
void
RGB
Get Signature
get RGB(): number[];Returns
number[]
This color components in [0 - 255] format. Alpha is omitted.
Set Signature
set RGB(values): void;Set this color components using [0 - 255] format. Alpha defaults to 255 if not provided.
Parameters
| Parameter | Type | Description |
|---|---|---|
values | number[] | 3 to 4 color channels |
Returns
void
A
Get Signature
get A(): number;Returns
number
This color alpha in [0 - 255] format.
Set Signature
set A(value): void;Set this color alpha in [0 - 255] format.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | number | Alpha value |
Returns
void
RGBA
Get Signature
get RGBA(): number[];Returns
number[]
This color components in [0 - 255] format.
Set Signature
set RGBA(values): void;Set this color components using [0 - 255] format.
Alias
Parameters
| Parameter | Type | Description |
|---|---|---|
values | number[] | 3 to 4 color channels |
Returns
void