Skip to content

@jakguru/vueprint / @jakguru/vueprint/utilities/colors

Module: @jakguru/vueprint/utilities/colors

Type Aliases

RgbChannelBlue

Ƭ RgbChannelBlue: number

A numeric value between 0 and 255 representing the blue channel of an RGB color

Defined in

src/utilities/colors.ts:25


RgbChannelGreen

Ƭ RgbChannelGreen: number

A numeric value between 0 and 255 representing the green channel of an RGB color

Defined in

src/utilities/colors.ts:21


RgbChannelRed

Ƭ RgbChannelRed: number

A numeric value between 0 and 255 representing the red channel of an RGB color

Defined in

src/utilities/colors.ts:17

Functions

colorToCssColor

colorToCssColor(color): string

Returns a CSS-safe color string

Parameters

NameTypeDescription
colorstringThe color to convert to a CSS color

Returns

string

The css-safe color string

Defined in

src/utilities/colors.ts:72


colorToCssWithAlpha

colorToCssWithAlpha(color, alpha?): undefined | string

Convert a color from a variety of formats to an RGBA string

Parameters

NameTypeDefault valueDescription
colorstringundefinedThe color to convert to an RGBA string
alphanumber1The alpha value to use for the RGBA string

Returns

undefined | string

an RGBA string

Defined in

src/utilities/colors.ts:194


colorToLottie

colorToLottie(color, alpha?): [number, number, number, number]

Convert a color from a variety of formats to a Lottie color array

Parameters

NameTypeDefault valueDescription
colorstringundefinedThe color to convert to a Lottie color array
alphanumber1The alpha value to use for the Lottie color array

Returns

[number, number, number, number]

a Lottie color array

Defined in

src/utilities/colors.ts:229


getColorMap

getColorMap(): Map<string, string>

Get a map of color names to their hex values

Returns

Map<string, string>

A map of color names to their hex values

Defined in

src/utilities/colors.ts:31


hexToRGBA

hexToRGBA(hex, alpha?): string

Get an RGBA string from a hex color

Parameters

NameTypeDefault valueDescription
hexstringundefinedThe hex color to convert to an RGBA string
alphanumber1The alpha value to use for the RGBA string

Returns

string

an RGBA string

Defined in

src/utilities/colors.ts:120


hexToRGBObject

hexToRGBObject(hex): Object

Get the hex value of a color

Parameters

NameTypeDescription
hexstringThe hex color to convert to an RGB object

Returns

Object

an object with the r, g, and b values of the hex color

NameType
bRgbChannelBlue
gRgbChannelGreen
rRgbChannelRed

b: RgbChannelBlue

The blue channel value


g: RgbChannelGreen

The green channel value


r: RgbChannelRed

The red channel value


Defined in

src/utilities/colors.ts:92


hslToRgb

hslToRgb(h, s, l): [RgbChannelRed, RgbChannelGreen, RgbChannelBlue]

Converts an HSL color value to RGB. Conversion formula adapted from this Wikipedia Article. Assumes h, s, and l are contained in the set [0, 1] and returns r, g, and b in the set [0, 255].

Parameters

NameTypeDescription
hnumberThe hue
snumberThe saturation
lnumberThe lightness

Returns

[RgbChannelRed, RgbChannelGreen, RgbChannelBlue]

The RGB representation

Defined in

src/utilities/colors.ts:159


hueToRgbChannelValue

hueToRgbChannelValue(p, q, t): RgbChannelRed | RgbChannelGreen | RgbChannelBlue

Converts a Hue value to its RGB representation, given intermediary values calculated from lightness and saturation. This function is a helper function, typically used within a larger algorithm to convert HSL colors to RGB format. It interpolates the RGB value based on the hue's position within its segment of the color wheel.

Parameters

NameTypeDescription
pnumberAn intermediary value calculated from the lightness, used to adjust the RGB value based on the lightness.
qnumberAnother intermediary value calculated from the lightness and saturation, used to fine-tune the RGB adjustment.
tnumberRepresents the hue component adjusted to fit within one of three ranges for RGB conversion. It should be modified based on the specific RGB channel (red, green, blue) being calculated.

Returns

RgbChannelRed | RgbChannelGreen | RgbChannelBlue

The calculated RGB channel value for a single channel: R, G, or B based on the input hue and intermediary values.

Defined in

src/utilities/colors.ts:135

Vueprint is a commercial work product released under the MIT License and is provided as-is with no warranty or guarantee of support.