颜色#
初始化颜色类#
使用下列构造函数之一来创建颜色:
The color(r, g, b) constructor creates a color using rgb values:
范围 |
描述 |
|---|---|
|
表示红色值的 0 至 255 范围内的整数。 |
|
表示绿色值的 0 至 255 范围内的整数。 |
|
表示蓝色值的 0 至 255 范围内的整数。 |
// 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:
范围 |
描述 |
|---|---|
|
A hexcode value or a predefined |
// 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.
类方法#
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 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.
参数 |
描述 |
|---|---|
|
网络格式的颜色值。 |
**返回:**表示颜色的整数值。
// 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.
返回: 0 - 360 度范围内的颜色色调。
saturation()#
The saturation() method returns the saturation of the color.
**返回:**颜色饱和度在 0 - 1.0 范围内。
brightness()#
The brightness() method returns the brightness of the color.
**返回:**颜色的亮度在 0 - 1.0 范围内。