pub struct Flags {
missing: Missing,
name: u8,
}
Expand description
Flags indicating DynamicColor
state.
The “missing” flags indicate whether a specific color component is missing (either the three color channels or the alpha channel).
The “named” flag represents whether the dynamic color was parsed from one of the named colors in CSS Color Module Level 4 § 6.1 or named color space functions in CSS Color Module Level 4 § 4.1.
The latter is primarily useful for serializing to a CSS-compliant string format.
Fields§
§missing: Missing
A bitset of missing color components.
name: u8
The named source a crate::DynamicColor
was constructed from. Meanings:
- 0 - not constructed from a named source;
- 255 - constructed from a named color space function;
- otherwise - the 1-based index into
crate::x11_colors::NAMES
.
Implementations§
Source§impl Flags
impl Flags
Sourcepub const fn from_missing(missing: Missing) -> Self
pub const fn from_missing(missing: Missing) -> Self
Construct flags with the given missing components.
Sourcepub fn set_missing(&mut self, missing: Missing)
pub fn set_missing(&mut self, missing: Missing)
Set the missing components.
Sourcepub(crate) fn set_named_color(&mut self, name_ix: usize)
pub(crate) fn set_named_color(&mut self, name_ix: usize)
Set the flags to indicate the color was specified as one of the named colors. name_ix
is
the index into crate::x11_colors::NAMES
.
Sourcepub(crate) fn set_named_color_space(&mut self)
pub(crate) fn set_named_color_space(&mut self)
Set the flags to indicate the color was specified using one of the named color space functions.
Sourcepub const fn named(self) -> bool
pub const fn named(self) -> bool
Returns true
if the flags indicate the color was generated from a named color or named
color space function.
Sourcepub const fn color_name(self) -> Option<&'static str>
pub const fn color_name(self) -> Option<&'static str>
If the color was constructed from a named color, returns that name.
See also parse_color
.
Sourcepub fn discard_name(&mut self)
pub fn discard_name(&mut self)
Discard the color name or color space name from the flags.