类: HSVColor
类: HSVColor
color.HSVColor
A color represented using [alpha], [hue], [saturation], and [value]. An [HSVColor] is represented in a parameter space that's based on human perception of color in pigments (e.g. paint and printer's ink). The representation is useful for some color computations (e.g. rotating the hue through the colors), because interpolation and picking of colors as red, green, and blue channels doesn't always produce intuitive results. The HSV color space models the way that different pigments are perceived when mixed. The hue describes which pigment is used, the saturation describes which shade of the pigment, and the value resembles mixing the pigment with different amounts of black or white pigment. See also:
- [HSLColor], a color that uses a color space based on human perception of colored light.
- HSV and HSL Wikipedia article, which this implementation is based upon.
目录
属性
方法
- _scaleAlpha
- equals
- toColor
- toString
- withAlpha
- withHue
- withSaturation
- withValue
- fromAHSV
- fromColor
- lerp
属性
alpha
• Readonly
alpha: number
Alpha, from 0.0 to 1.0. The describes the transparency of the color. A value of 0.0 is fully transparent, and 1.0 is fully opaque.
hue
• Readonly
hue: number
Hue, from 0.0 to 360.0. Describes which color of the spectrum is represented. A value of 0.0 represents red, as does 360.0. Values in between go through all the hues representable in RGB. You can think of this as selecting which pigment will be added to a color.
saturation
• Readonly
saturation: number
Saturation, from 0.0 to 1.0. This describes how colorful the color is. 0.0 implies a shade of grey (i.e. no pigment), and 1.0 implies a color as vibrant as that hue gets. You can think of this as the equivalent of how much of a pigment is added.
value
• Readonly
value: number
Value, from 0.0 to 1.0. The "value" of a color that, in this context, describes how bright a color is. A value of 0.0 indicates black, and 1.0 indicates full intensity color. You can think of this as the equivalent of removing black from the color as value increases.
方法
_scaleAlpha
▸ _scaleAlpha(factor
): HSVColor
参数
名称 | 类型 |
---|---|
factor |
number |
返回值
equals
▸ equals(other
): boolean
参数
名称 | 类型 |
---|---|
other |
any |
返回值
boolean
toColor
▸ toColor(): Color
Returns this color in RGB.
返回值
toString
▸ toString(): string
返回值
string
withAlpha
▸ withAlpha(alpha
): HSVColor
Returns a copy of this color with the [alpha] parameter replaced with the given value.
参数
名称 | 类型 |
---|---|
alpha |
number |
返回值
withHue
▸ withHue(hue
): HSVColor
Returns a copy of this color with the [hue] parameter replaced with the given value.
参数
名称 | 类型 |
---|---|
hue |
number |
返回值
withSaturation
▸ withSaturation(saturation
): HSVColor
Returns a copy of this color with the [saturation] parameter replaced with the given value.
参数
名称 | 类型 |
---|---|
saturation |
number |
返回值
withValue
▸ withValue(value
): HSVColor
Returns a copy of this color with the [value] parameter replaced with the given value.
参数
名称 | 类型 |
---|---|
value |
number |
返回值
fromAHSV
▸ Static
fromAHSV(alpha
, hue
, saturation
, value
): HSVColor
Creates a color.
All the arguments must not be null and be in their respective ranges. See the fields for each parameter for a description of their ranges.
参数
名称 | 类型 |
---|---|
alpha |
number |
hue |
number |
saturation |
number |
value |
number |
返回值
fromColor
▸ Static
fromColor(color
): HSVColor
Creates an [HSVColor] from an RGB [Color].
This constructor does not necessarily round-trip with [toColor] because of floating point imprecision.
参数
名称 | 类型 |
---|---|
color |
Color |
返回值
lerp
▸ Static
lerp(a
, b
, t
): undefined
| HSVColor
Linearly interpolate between two HSVColors.
The colors are interpolated by interpolating the [alpha], [hue], [saturation], and [value] channels separately, which usually leads to a more pleasing effect than [Color.lerp] (which interpolates the red, green, and blue channels separately).
If either color is null, this function linearly interpolates from a transparent instance of the other color. This is usually preferable to interpolating from [Colors.transparent] (const Color(0x00000000)
) since that will interpolate from a transparent red and cycle through the hues to match the target color, regardless of what that color's hue is.
Values outside of the valid range for each channel will be clamped.
参数
名称 | 类型 |
---|---|
a |
null | HSVColor |
b |
null | HSVColor |
t |
number |
返回值
undefined
| HSVColor