颜色#
初始化颜色类#
使用以下构造函数创建颜色:
Color(value)
此构造函数使用一个参数:
范围 |
描述 |
---|---|
|
颜色值。可以通过四种不同的方式指定:
|
用十六进制值构造。
# Construct a yellow Color "yellow" with the Color class.
yellow = Color(0xfff700)
使用 RGB 值构建。
# Construct a yellow Color "yellow" with the Color class.
yellow = Color(255, 247, 0)
用网络字符串构建。
# Construct a yellow Color "yellow" with the Color class.
yellow = Color("#fff700")
使用现有的颜色类型构建。
# 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.
类方法#
rgb()#
The rgb(value)
method changes the existing color instance using RGB values.
参数 |
描述 |
---|---|
价值 |
要转换为 rgb 值的颜色值。 |
**返回:**表示颜色的整数值。
# 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.
参数 |
描述 |
---|---|
色调 |
表示颜色色调的 0 至 360 之间的整数。 |
饱和 |
从 0.0 到 1.0 的双精度值,表示颜色的饱和度。 |
价值 |
从 0.0 到 1.0 的双精度数,表示颜色的亮度。 |
**返回:**表示颜色的整数值。
# 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.
参数 |
描述 |
---|---|
价值 |
网络格式的颜色值。 |
**返回:**表示颜色的整数值。
# 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.