Class Color
Color generation and conversion class.
constructor (r: number, g: number, b: number, a: number): Color
Name | Type | Default | Description |
r | number | | |
g | number | | |
b | number | | |
a | number | 1 | |
Property .a : number
Default value: 1
Accessor .brightness : number
Get the brightness of this color.
Accessor .chroma : number
Accessor .hex : string
Converts this color to a hex string.
Accessor .hsl
Converts this color to an HSL array.
Accessor .rgb : string
Converts this color to an rgba string.
Method .copy (): Color
Creates a copy of this color.
Method .toString (): string
static Method .from (color: string|Color): Color
Name | Type | Default | Description | |
color | string | Color | | |
static Method .fromHex (hex: string): Color
Creates a Color instance from a hex string.
Name | Type | Default | Description |
hex | string | | |
static Method .fromHsl (h: number, s: number, l: number): Color
Name | Type | Default | Description |
h | number | | |
s | number | | |
l | number | | |
static Method .fromRgb (color: string): Color
Name | Type | Default | Description |
color | string | | |
static Method .gradient (colors: Array<string|Color>, steps: number): Array<Color>
Generates a rainbow gradient with a given number of steps.
Name | Type | Default | Description | |
colors | Array<string | Color> | | |
steps | number | | | |
static Method .mix (c1: string|Color, c2: string|Color, p: number): Color
Linearly interpolates two colors or hex strings.
Name | Type | Default | Description | |
c1 | string | Color | | |
c2 | string | Color | | |
p | number | 0.5 | | |
static Method .mixMany (colors: Array<Color>, weights: Array<number>): Color
Name | Type | Default | Description |
colors | Array<Color> | | |
weights | Array<number> | | |
static Method .rainbow (steps: number): Array<Color>
Generates a rainbow gradient with a given number of steps.
Name | Type | Default | Description |
steps | number | | |
static Method .shades (color: string|Color, steps: number, range: number): Array<Color>
Name | Type | Default | Description | |
color | string | Color | | |
steps | number | | | |
range | number | 0.5 | | |