color#
Initializing the color Class#
A color is created by using one of the following constructors:
The color(r, g, b)
constructor creates a color using rgb values:
Parameter |
Description |
---|---|
r |
An integer in the range 0 to 255 representing the red value. |
g |
An integer in the range 0 to 255 representing the green value. |
b |
An integer in the range 0 to 255 representing the blue value. |
// Construct a yellow color "Yellow" with the color class
// using rgb values.
color Yellow = color(255, 247, 0);
The color(value)
constructor creates a color using rgb values:
Parameter |
Description |
---|---|
value |
A hexcode value or a predefined ColorType. |
// Construct a yellow Color "yellow" with the Color class
// using a Hexcode.
color Yellow = color(0xFFF700);
// Construct a yellow Color "yellow" with the Color class
// using a predefined color.
color Yellow = color(yellow);
This Yellow
object will be used in all subsequent examples throughout this API documentation when referring to Color class methods.
Class Methods#
hsv()#
The hsv(hue, saturation, value)
method changes the existing color instance using hsv.
Parameters |
Description |
---|---|
hue |
An integer from 0 - 360 that represents the hue of the color. |
saturation |
A double from 0.0 - 1.0 that represents the saturation of the color. |
value |
A double from 0.0 - 1.0 that represents the brightness of the color. |
Returns: An integer value representing the color.
// Change Yellow to a color that is red using HSV values.
Yellow.hsv(0, 1.0, 1.0);
web()#
The web(value)
method changes the existing color instance using webstring.
Parameters |
Description |
---|---|
value |
The color value in web format. |
Returns: An integer value representing the color.
// Change Yellow to a color that is red using a Hexcode.
Yellow.web("#ff0000");
isTransparent()#
The isTransparent()
method returns if the color is transparent or not.
Returns: true
if the color is transparent. false
if it is not.
hue()#
The hue()
method returns the hue of the color.
Returns: The hue of the color in the range 0 - 360 degrees.
saturation()#
The saturation()
method returns the saturation of the color.
Returns: The saturation of the color in the range 0 - 1.0.
brightness()#
The brightness()
method returns the brightness of the color.
Returns: The brightness of the color in the range 0 - 1.0.