CGSGColor Class
Some utils methods extending the Array prototype
Item Index
Methods
_toHex
-
n
Parameters:
-
n
StringString or Number representation of a number between 0 and 255
Returns:
Example "A6"
fromString
-
rgb
Convert a String to an {r,g, b} object.
Parameters:
-
rgb
String
Returns:
Example:
CGSGColor.fromString("rgb(121, 333, 444)"); returns {r:121, b:333, c:444};
hex2rgb
-
hex
Convert an hexadecimal code for color to R, G and B
Parameters:
-
hex
Stringan hexadecimal code, with or without the starting sharp (#)
Returns:
an object encapsulating r, g and b values (from 0 to 255)
hsl2rgb
-
h
-
s
-
l
HSL to RGB converter. Adapted from http://en.wikipedia.org/wiki/HSL_color_space
Returns:
A {r, g, b} object
hsv2rgb
-
h
-
s
-
v
HSV to RGB converter. Adapted from http://en.wikipedia.org/wiki/HSV_color_space
Returns:
A {r, g, b} object
lerp
-
colorFrom
-
colorTo
-
weight
Linear interpolation between 2 colors
Returns:
a heh value for the interpolated color
rgb2hex
-
r
-
g
-
b
Convert R, G and B value to an hexadecimal code
Parameters:
Returns:
an hexadecimal value for the color, starting with a sharp (#)
rgb2hsl
-
r
-
g
-
b
RGB to HSL converter. Adapted from http://en.wikipedia.org/wiki/HSL_color_space