Color

Color

Methods

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

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

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

Create a hex color from RGB values.
Source:
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}

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.
Source:
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:
Type:
string
The hex color string.

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

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].
Source:
Parameters:
Name Type Description
h number The hue.
s number The saturation.
l number The lightness.
Returns:
Type:
object
The RGB representation.

(static) hue2rgb(p, q, t) → {number}

Converts an HSL representation to RGB.
Source:
Parameters:
Name Type Description
p number
q number
t number
Returns:
Type:
number
RGB representation of component.

(static) randomBlue() → {string}

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

(static) randomGreen() → {string}

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

(static) randomRed() → {string}

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

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

Convert RGB to a hex string.
Source:
Parameters:
Name Type Description
r number Red component.
g number Green component.
b number Blue component.
Returns:
Type:
string
Hex representation.

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

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].
Source:
Parameters:
Name Type Description
r number The red color value.
g number The green color value.
b number The blue color value.
Returns:
Type:
array
The HSL representation.

toString() → {string}

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