Skip to main content

Color

Type Alias Color 

Source
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

Source

pub const TRANSPARENT_BLACK: Self

A fully transparent color.

Source

pub const BLACK: Self

An opaque black color.

Source

pub const WHITE: Self

An opaque white color.

Source

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.

Source

pub fn resolve_to_absolute( &self, current_color: &AbsoluteColor, ) -> AbsoluteColor

Combine this complex color with the given foreground color into an absolute color.

Source

fn contrast_ratio(a: &AbsoluteColor, b: &AbsoluteColor) -> f32

Trait Implementations§

Source§

impl ToCss for Color

Source§

fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Result
where W: Write,

Serialize self in CSS syntax, writing to dest.
Source§

fn to_css_string(&self) -> String

Serialize self in CSS syntax and return a string. Read more
Source§

fn to_css_cssstring(&self) -> String

Serialize self in CSS syntax and return a CssString. Read more
Source§

impl ToResolvedValue for Color

Source§

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

Convert a resolved value to a resolved value.
Source§

fn from_resolved_value(resolved: Self::ResolvedValue) -> Self

Convert a resolved value to resolved value form.