Class: Color
utils/color.Color
Represents a color value such as rgba(255, 1, 100, 255), #FEFEFE or lightblue to allow for easy conversion between color representations
Constructors
constructor
โข new Color(color)
Creates a Color instance from a ColorLike representation.
Parameters
| Name | Type | Description |
|---|---|---|
color | ColorLike | The ColorLike representation to use when creating the Color instance |
Defined in
src/utils/color.ts:32
Properties
hex
โข hex: string
Defined in
src/utils/color.ts:23
html
โข html: Object
Index signature
โช [index: string]: string
Defined in
src/utils/color.ts:191
original
โข original: string | RGBAColor
Defined in
src/utils/color.ts:22
rgba
โข rgba: RGBAColor
Defined in
src/utils/color.ts:24
webgl
โข webgl: number[]
Defined in
src/utils/color.ts:25
Methods
hexToRgba
โธ hexToRgba(hex): RGBAColor
Converts a valid hex color to rgba.
throws When an invalid hex color is provided
Parameters
| Name | Type | Description |
|---|---|---|
hex | string | The hex color to convert to rgba |
Returns
The rgba equivalent of the hex color
Defined in
src/utils/color.ts:135
parseHEX
โธ parseHEX(color): void
Takes in a hex color then converts it to rgba and webgl and stores the conversions.
Parameters
| Name | Type | Description |
|---|---|---|
color | string | The hex color to parse |
Returns
void
Defined in
src/utils/color.ts:107
parseHTML
โธ parseHTML(color): void
Takes in a html color then converts it to hex, rgba and webgl and stores the conversions.
Parameters
| Name | Type | Description |
|---|---|---|
color | string | The html color to parse |
Returns
void
Defined in
src/utils/color.ts:120
parseRGBA
โธ parseRGBA(color): void
Takes in a rgba color then converts it to hex and webgl and stores the conversions.
Parameters
| Name | Type | Description |
|---|---|---|
color | RGBAColor | The rgba color to parse |
Returns
void
Defined in
src/utils/color.ts:93
rgbaToHex
โธ rgbaToHex(rgba): string
Converts a valid rgba color to hex.
throws When an invalid rgba color is provided
Parameters
| Name | Type | Description |
|---|---|---|
rgba | RGBAColor | The rgba color to convert to hex |
Returns
string
The hex equivalent of the rgba color
Defined in
src/utils/color.ts:163
rgbaToWebGL
โธ rgbaToWebGL(rgba): number[]
Converts a valid rgba color to webgl.
throws When an invalid rgba color is provided
Parameters
| Name | Type | Description |
|---|---|---|
rgba | RGBAColor | The rgba color to convert to a webgl color representation |
Returns
number[]
The webgl equivalent of the rgba color
Defined in
src/utils/color.ts:185
validateHEX
โธ validateHEX(color): boolean
Validates a hex color.
Parameters
| Name | Type | Description |
|---|---|---|
color | string | The hex color to validate |
Returns
boolean
Wether or not the color is a valid hex color
Defined in
src/utils/color.ts:73
validateHTML
โธ validateHTML(color): boolean
Validates a html color.
Parameters
| Name | Type | Description |
|---|---|---|
color | string | The html color to validate |
Returns
boolean
Wether or not the color is a valid html color
Defined in
src/utils/color.ts:84
validateRGBA
โธ validateRGBA(color): boolean
Validates a rgba color.
Parameters
| Name | Type | Description |
|---|---|---|
color | RGBAColor | The rgba color to validate |
Returns
boolean
Wether or not the color is a valid rgba color
Defined in
src/utils/color.ts:54