Color

Color~ Color

new Color(r, g, b)

Source:
Construct a new color.
Parameters:
Name Type Description
r number
g number
b number

Methods

(static) average(colorOne, colorTwo) → {string}

Source:
Generate the average of two hex colors.
Parameters:
Name Type Description
colorOne string First hex color.
colorTwo string Second hex color.
Returns:
Averaged hex color.
Type
string

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

Source:
Create a hex color from RGB values.
Parameters:
Name Type Description
r number Red value.
g number Green value.
b number Blue value .
Returns:
Type
string

(static) createFromRGBL(r, g, b, l) → {string}

Source:
Creates a hex color string from a (r,g,b) value as well as a lightness value l from [0, 1]. To do this we convert the rgb color to hsl. Then we modify the l, take it back to rgb, and then convert to a color string.
Parameters:
Name Type Description
r number The red color value.
g number The green color value.
b number The blue color value.
l number The lightness value [0,1].
Returns:
The hex color string.
Type
string

(static) getColor(colorString) → {string}

Source:
Gets the hex string (#RRGGBB) for a color name.
Parameters:
Name Type Description
colorString string Name of color ('red', 'purple', etc.)
Returns:
Hex string #RRGGBB
Type
string

(static) hslToRgb(h, s, l) → {object}

Source:
Converts an HSL color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes h, s, and l are contained in the set [0, 1] and returns r, g, and b in the set [0, 255].
Parameters:
Name Type Description
h number The hue.
s number The saturation.
l number The lightness.
Returns:
The RGB representation.
Type
object

(static) randomBlue() → {string}

Source:
Generate a random blue value.
Returns:
Hex representation of random blue color.
Type
string

(static) randomGreen() → {string}

Source:
Generate a random green value.
Returns:
Hex representation of random green color.
Type
string

(static) randomRed() → {string}

Source:
Generate a random red value.
Returns:
Hex representation of random red color.
Type
string

(static) rgbToHsl(r, g, b) → {array}

Source:
Converts an RGB color value to HSL. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes r, g, and b are contained in the set [0, 255] and returns h, s, and l in the set [0, 1].
Parameters:
Name Type Description
r number The red color value.
g number The green color value.
b number The blue color value.
Returns:
The HSL representation.
Type
array

toString() → {string}

Source:
Generate a hex representation of the color.
Returns:
Type
string