pub struct Color {
pub red: u8,
pub green: u8,
pub blue: u8,
pub alpha: u8,
}Expand description
A colour with 8 bits per channel.
The chart pipeline packs colours into a single u32 (0xRRGGBBAA)
before they reach the GPU, so the type keeps the four channels as
separate bytes and does the packing once, at upload time.
Fields§
§red: u8The red channel.
green: u8The green channel.
blue: u8The blue channel.
alpha: u8The alpha channel, where 255 is fully opaque.
Implementations§
Source§impl Color
Inherent implementation of Color.
impl Color
Inherent implementation of Color.
Sourcepub fn lerp(self, other: Self, amount: f64) -> Self
pub fn lerp(self, other: Self, amount: f64) -> Self
Returns the colour that lies between two colours.
The channels are mixed one by one, which is what the ramp of a visual map does: the middle of the ramp is the middle of its two ends.
§Arguments
f64- The opposite endpoint of the interpolation.Self- The opposite endpoint of the interpolation.
Sourcepub fn parse(input: &str) -> Option<Self>
pub fn parse(input: &str) -> Option<Self>
Parses a CSS colour string.
The accepted forms are the ones ECharts accepts: #rgb, #rgba,
#rrggbb, #rrggbbaa, rgb(), rgba(), hsl(), hsla(),
transparent, and the CSS named colours. Returns None when the
string is not a colour.
§Arguments
&str- Shared reference to astr.
§Returns
Option<Self>-Some(...)on success,Noneotherwise.
Sourcepub fn with_alpha(self, alpha: u8) -> Self
pub fn with_alpha(self, alpha: u8) -> Self
Sourcepub fn mix(self, other: Self, ratio: f64) -> Self
pub fn mix(self, other: Self, ratio: f64) -> Self
Returns the colour mixed with another one.
ratio is the weight of other: 0.0 returns this colour
unchanged, 1.0 returns other.
§Arguments
f64- A 64-bit float (f64).Self- ASelfparameter.