Skip to main content

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

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

NameTypeDescription
hexstringThe hex color to convert to rgba

Returns

RGBAColor

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

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

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

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

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

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

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

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

NameTypeDescription
colorRGBAColorThe rgba color to validate

Returns

boolean

Wether or not the color is a valid rgba color

Defined in

src/utils/color.ts:54