pub type Color = GenericColor<Percentage>;Expand description
A computed value for <color>.
Aliased Type§
#[repr(C)]pub enum Color {
Absolute(AbsoluteColor),
ColorFunction(Box<ColorFunction<GenericColor<Percentage>>>),
CurrentColor,
ColorMix(Box<GenericColorMix<GenericColor<Percentage>, Percentage>>),
ContrastColor(Box<GenericColor<Percentage>>),
}Variants§
Absolute(AbsoluteColor)
The actual numeric color.
ColorFunction(Box<ColorFunction<GenericColor<Percentage>>>)
A unresolvable color.
CurrentColor
The CurrentColor keyword.
ColorMix(Box<GenericColorMix<GenericColor<Percentage>, Percentage>>)
The color-mix() function.
ContrastColor(Box<GenericColor<Percentage>>)
The contrast-color() function.
Implementations§
Source§impl Color
impl Color
Sourcepub const TRANSPARENT_BLACK: Self
pub const TRANSPARENT_BLACK: Self
A fully transparent color.
Sourcepub fn from_color_mix(color_mix: ColorMix) -> Self
pub fn from_color_mix(color_mix: ColorMix) -> Self
Create a new computed Color from a given color-mix, simplifying it to an absolute color
if possible.
Sourcepub fn resolve_to_absolute(
&self,
current_color: &AbsoluteColor,
) -> AbsoluteColor
pub fn resolve_to_absolute( &self, current_color: &AbsoluteColor, ) -> AbsoluteColor
Combine this complex color with the given foreground color into an absolute color.
fn contrast_ratio(a: &AbsoluteColor, b: &AbsoluteColor) -> f32
Trait Implementations§
Source§impl ToCss for Color
impl ToCss for Color
Source§fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Resultwhere
W: Write,
fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Resultwhere
W: Write,
Serialize
self in CSS syntax, writing to dest.Source§fn to_css_string(&self) -> String
fn to_css_string(&self) -> String
Serialize
self in CSS syntax and return a string. Read moreSource§fn to_css_cssstring(&self) -> String
fn to_css_cssstring(&self) -> String
Serialize
self in CSS syntax and return a CssString. Read moreSource§impl ToResolvedValue for Color
impl ToResolvedValue for Color
Source§type ResolvedValue = GenericColor<Percentage>
type ResolvedValue = GenericColor<Percentage>
The resolved value type we’re going to be converted to.
Source§fn to_resolved_value(self, context: &Context<'_>) -> Self::ResolvedValue
fn to_resolved_value(self, context: &Context<'_>) -> Self::ResolvedValue
Convert a resolved value to a resolved value.
Source§fn from_resolved_value(resolved: Self::ResolvedValue) -> Self
fn from_resolved_value(resolved: Self::ResolvedValue) -> Self
Convert a resolved value to resolved value form.