Class pv.Color
Represents an abstract (possibly translucent) color. The color is divided into two parts: the color attribute, an opaque color format string, and the opacity attribute, a float in [0, 1]. The color space is dependent on the implementing class; all colors support the #rgb method to convert to RGB color space for interpolation.
See also the Color guide.
Defined in: Color.js.
Constructor Attributes | Constructor Name and Description |
---|---|
pv.Color(color, opacity)
Constructs a color with the specified color format string and opacity.
|
Field Attributes | Field Name and Description |
---|---|
An opaque color format string, such as "#f00".
|
|
The opacity, a float in [0, 1].
|
Method Attributes | Method Name and Description |
---|---|
brighter(k)
Returns a new color that is a brighter version of this color.
|
|
darker(k)
Returns a new color that is a brighter version of this color.
|
|
rgb()
Returns the RGB color equivalent to this color.
|
Class Detail
pv.Color(color, opacity)
Constructs a color with the specified color format string and opacity. This
constructor should not be invoked directly; use pv.color instead.
- Parameters:
- {string} color
- an opaque color format string, such as "#f00".
- {number} opacity
- the opacity, in [0,1].
- See:
- pv.color
Field Detail
{string}
color
An opaque color format string, such as "#f00".
{number}
opacity
The opacity, a float in [0, 1].
Method Detail
{pv.Color}
brighter(k)
Returns a new color that is a brighter version of this color. The behavior of
this method may vary slightly depending on the underlying color space.
Although brighter and darker are inverse operations, the results of a series
of invocations of these two methods might be inconsistent because of rounding
errors.
- Parameters:
- k Optional
- {number} an optional scale factor; defaults to 1.
- Returns:
- {pv.Color} a brighter color.
- See:
- #darker
{pv.Color}
darker(k)
Returns a new color that is a brighter version of this color. The behavior of
this method may vary slightly depending on the underlying color space.
Although brighter and darker are inverse operations, the results of a series
of invocations of these two methods might be inconsistent because of rounding
errors.
- Parameters:
- k Optional
- {number} an optional scale factor; defaults to 1.
- Returns:
- {pv.Color} a darker color.
- See:
- #brighter
{pv.Color.Rgb}
rgb()
Returns the RGB color equivalent to this color. This method is abstract and
must be implemented by subclasses.
- Returns:
- {pv.Color.Rgb} an RGB color.