Color
Extends Object.
Instantiation
You can instantiate a new Color object by supplying a hexadecimal value, or a string:
<?ev
// new Color() using hexadecimal
var red = new Color('#ff0000');
// new Color() using a string
var red = new Color('red');
?>
Construct parameters |
---|
color
String
If the color supplied is a valid hexadecimal value, the Color object will return the hexadecimal value.
If the color supplied is not a valid hexadecimal value, but is a known color, the Color object will return
the long hexadecimal value.
If the color supplied is not a valid hexadecimal value, nor is it a known color, the Color object will generate and return a hexadecimal value.
|
Methods |
---|
blue([value])
Number
| Color
Gets or sets a value (0 to 255) for the blue channel of the Color. |
darken([amount])
Color
Decrease the light value (100% to 0%) of your color by the amount provided, a new color object with the new hexadecimal value will be returned. Parameters
Example
|
green([value])
Number
| Color
Gets or sets a value (0 to 255) for the green channel of the Color. |
hex()
String
Returns the hexadecimal value as a string with the '#' prefix. |
hsl()
Array
Returns an Array containing the hue (h), saturation (s) and lightness (l) values for the Color. |
hsla()
Array
Returns an Array containing the hue (h), saturation (s), lightness (l) and opacity (a) values for the Color. |
hue([value])
Number
| Color
Gets or sets the hue value of the Color (0 to 360). |
isDark([threshold])
Boolean
The threshold parameter is optional and will default to 130. If your color's light value (0 to 255) is less than or equal to the threshold, the method will return true.
|
isHex()
Boolean
Returns true if the color model in use is hexadecimal. |
isHsl()
Boolean
Returns true if the color model in use is HSL. |
isLight([threshold])
Boolean
The threshold parameter is optional and will default to 130. If your color's light value (0 to 255) is greater than the threshold, the method will return true.
|
isOpaque()
Boolean
Returns true if there is no opacity (1). |
isRgb()
Boolean
Returns true if the color model in use is RGB. |
isSolid()
Boolean
Returns true if the color has no opacity (same as isOpaque). |
isTransparent()
Boolean
Returns true if the color has an opacity of zero. |
lighten([amount])
Color
The amount parameter is optional and will default to 10. Increase the light value (0% to 100%) of your color by the amount provided, a new color object with the new hexadecimal value will be returned.
|
lightness([value])
Number
| Color
Gets or sets the lightness value of the Color (0 to 100). |
opacity([value])
Number
| Color
Get or set the opacity value of your color from 0 (transparent) to 1 (opaque), a new color object with the new rgba value will be returned when setting the opacity.
|
red([value])
Number
| Color
Gets or sets a value (0 to 255) for the red channel of the Color. |
rgb()
Array
Returns the red, green and blue values of your color in an array. |
rgba()
Array
Returns the red, green, blue and alpha/opacity values of your color in an array. |
saturation([value])
Number
| Color
Gets or sets the saturation value of the Color (0 to 100). |
toHex()
Color
Change the color model to hexadecimal. |
toHsl()
Color
Change the color model to HSL. |
toRgb()
Color
Change the color model to RGB. |
toString()
String
If an opacity has been applied to the color, this method returns the rgba as a comma-seperated string, wrapped within "rgba()". Otherwise, this method returns the hexadecimal value as a string.
|