Color#
Initializing the Color Class#
The Color
constructor creates a Color object.
Parameter |
Description |
---|---|
|
The color’s value. This can be specified in four different ways:
|
Constructing with a Hex value.
# Construct a yellow Color "yellow" with the Color class.
yellow = Color(0xfff700)
Constructing with RGB values.
# Construct a yellow Color "yellow" with the Color class.
yellow = Color(255, 247, 0)
Constructing with a web string.
# Construct a yellow Color "yellow" with the Color class.
yellow = Color("#fff700")
Constructing with an existing Color Type.
# Construct a yellow Color "yellow" with the Color class.
yellow = Color(Color.YELLOW)
This yellow
object will be used in all subsequent examples throughout this API documentation when referring to Color class methods.
Class Methods#
rgb()#
The rgb(value)
method changes the existing color instance using RGB values.
Parameters |
Description |
---|---|
value |
The color value to be changed into an rgb value. |
Returns: An integer value representing the color.
# Change "yellow" to a different color using RGB values.
yellow.rgb(255, 200, 0)
hsv()#
The hsv(hue, saturation, value)
method changes the existing color instance using hsv.
Parameters |
Description |
---|---|
hue |
An integer from 0 to 360 that represents the hue of the color. |
saturation |
A double from 0.0 to 1.0 that represents the saturation of the color. |
value |
A double from 0.0 to 1.0 that represents the brightness of the color. |
Returns: An integer value representing the color.
# Change yellow to a different color using HSV values.
color.hsv(47, 1, 1)
web()#
The web(value)
method changes the existing color instance using a webstring.
Parameters |
Description |
---|---|
value |
The color value in web format. |
Returns: An integer value representing the color.
# Change yellow to a different color using a webstring value.
yellow.web("#ffc800")
is_transparent()#
The is_transparent()
method returns if the color is transparent or not.
Returns: True
if the color is transparent. False
if it is not.