pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}Expand description
An 8-bit-per-channel RGBA color value.
A plain color value (fill / text / box color), independent of any colorimetry
metadata (ColorSpace et al.). a is the alpha channel: 255 = opaque,
0 = fully transparent.
Fields§
§r: u8Red channel (0–255).
g: u8Green channel (0–255).
b: u8Blue channel (0–255).
a: u8Alpha channel (0 = transparent, 255 = opaque).
Implementations§
Source§impl Color
impl Color
Sourcepub const TRANSPARENT: Self
pub const TRANSPARENT: Self
Fully transparent (black with zero alpha).
Sourcepub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self
Creates a color with an explicit alpha channel.
Sourcepub fn parse_ffmpeg(s: &str) -> Option<Self>
pub fn parse_ffmpeg(s: &str) -> Option<Self>
Parses an FFmpeg colour string, as -vf drawbox=color=... and friends
accept it.
Recognised forms:
#RRGGBB/#RRGGBBAAand0xRRGGBB/0xRRGGBBAA- a colour name, matched case-insensitively (
"green","DarkOrchid") - either of the above with an
@alphasuffix, where alpha is a float in0.0..=1.0or a two-digit0xAA
Returns None for anything else, including FFmpeg’s random — it has no
fixed value, so there is nothing to return.
Alpha defaults to opaque when the form does not carry one.
Sourcepub fn ffmpeg_color_names() -> impl ExactSizeIterator<Item = (&'static str, Self)>
pub fn ffmpeg_color_names() -> impl ExactSizeIterator<Item = (&'static str, Self)>
Every colour name parse_ffmpeg accepts, with its
value, in ascending name order.
Lets a host offer the same palette FFmpeg understands (a colour picker,
an autocomplete), and it is what
crates/ff-filter/tests/color_parse_reference_tests.rs walks to re-check
every row against the linked FFmpeg.