Color

Methods

(static) rgbaCssColor(r, g, b, aopt) → {string}

Convert 4 r,g,b,a ints in [0-255] ("a" defaulted to 255) to a css color string.

Parameters:
NameTypeAttributesDefaultDescription
rnumber

integer in [0, 255] for red channel

gnumber

integer in [0, 255] for green channel

bnumber

integer in [0, 255] for blue channel

anumber<optional>
255

integer in [0, 255] for alpha/opacity channel

Returns:

A rgb(r,g,b) or rgba(r,g,b,a) css color string

Type: 
string

(static) hslCssColor(h, sopt, lopt, aopt) → {string}

Convert 4 ints, h,s,l,a, h in [0-360], s,l in [0-100]% a in [0-255] to a css color string. See hsl().

NOTE: h=0 and h=360 are the same, use h in 0-359 for unique colors.

Parameters:
NameTypeAttributesDefaultDescription
hnumber
snumber<optional>
100
lnumber<optional>
50
anumber<optional>
255
Returns:

A css HSL color string

Type: 
string

(static) hexCssColor(r, g, b) → {string}

Return a html/css hex color string for an r,g,b opaque color (a=255). Hex strings do not support alpha. Both #nnn and #nnnnnn forms supported. Default is to check for the short hex form.

Parameters:
NameTypeDescription
rnumber

Integer value for red channel

gnumber

Integer value for green channel

bnumber

Integer value for blue channel

Returns:

A css hex color string #nnn or #nnnnnn, n in [0,F] hex

Type: 
string