pub enum Color {
CurrentColor,
Absolute(Box<Absolute>),
ColorMix(Box<ColorMix>),
LightDark(Box<LightDark>),
}
Expand description
Specified color value
Variants§
CurrentColor
The ‘currentColor’ keyword
Absolute(Box<Absolute>)
An absolute color. https://w3c.github.io/csswg-drafts/css-color-4/#typedef-absolute-color-function
ColorMix(Box<ColorMix>)
A color mix.
LightDark(Box<LightDark>)
A light-dark() color.
Implementations§
source§impl Color
impl Color
fn parse_internal<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, preserve_authored: PreserveAuthored ) -> Result<Self, ParseError<'i>>
sourcepub fn is_valid(context: &ParserContext<'_>, input: &mut Parser<'_, '_>) -> bool
pub fn is_valid(context: &ParserContext<'_>, input: &mut Parser<'_, '_>) -> bool
Returns whether a given color is valid for authors.
sourcepub fn parse_and_compute(
context: &ParserContext<'_>,
input: &mut Parser<'_, '_>,
device: Option<&Device>
) -> Option<ComputedColor>
pub fn parse_and_compute( context: &ParserContext<'_>, input: &mut Parser<'_, '_>, device: Option<&Device> ) -> Option<ComputedColor>
Tries to parse a color and compute it with a given device.
source§impl Color
impl Color
sourcepub fn honored_in_forced_colors_mode(&self, allow_transparent: bool) -> bool
pub fn honored_in_forced_colors_mode(&self, allow_transparent: bool) -> bool
Returns whether this color is allowed in forced-colors mode.
sourcepub fn currentcolor() -> Self
pub fn currentcolor() -> Self
Returns currentcolor value.
sourcepub fn transparent() -> Self
pub fn transparent() -> Self
Returns transparent value.
sourcepub fn from_absolute_color(color: AbsoluteColor) -> Self
pub fn from_absolute_color(color: AbsoluteColor) -> Self
Create a color from an AbsoluteColor
.
sourcepub fn parse_quirky<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks
) -> Result<Self, ParseError<'i>>
pub fn parse_quirky<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks ) -> Result<Self, ParseError<'i>>
Parse a color, with quirks.
https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk
fn parse_hash<'i>( bytes: &[u8], loc: &SourceLocation ) -> Result<Self, ParseError<'i>>
sourcefn parse_quirky_color<'i, 't>(
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>>
fn parse_quirky_color<'i, 't>( input: &mut Parser<'i, 't> ) -> Result<Self, ParseError<'i>>
Parse a
https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk
source§impl Color
impl Color
sourcepub fn to_computed_color(
&self,
context: Option<&Context<'_>>
) -> Option<ComputedColor>
pub fn to_computed_color( &self, context: Option<&Context<'_>> ) -> Option<ComputedColor>
Converts this Color into a ComputedColor.
If context
is None
, and the specified color requires data from
the context to resolve, then None
is returned.
Trait Implementations§
source§impl From<AbsoluteColor> for Color
impl From<AbsoluteColor> for Color
source§fn from(value: AbsoluteColor) -> Self
fn from(value: AbsoluteColor) -> Self
Converts to this type from the input type.
source§impl FromParsedColor for Color
impl FromParsedColor for Color
source§fn from_current_color() -> Self
fn from_current_color() -> Self
Construct a new color from the CSS
currentcolor
keyword.source§fn from_rgba(
red: ColorComponent<u8>,
green: ColorComponent<u8>,
blue: ColorComponent<u8>,
alpha: ColorComponent<NumberOrPercentage>
) -> Self
fn from_rgba( red: ColorComponent<u8>, green: ColorComponent<u8>, blue: ColorComponent<u8>, alpha: ColorComponent<NumberOrPercentage> ) -> Self
Construct a new color from red, green, blue and alpha components.
source§fn from_hsl(
hue: ColorComponent<NumberOrAngle>,
saturation: ColorComponent<NumberOrPercentage>,
lightness: ColorComponent<NumberOrPercentage>,
alpha: ColorComponent<NumberOrPercentage>
) -> Self
fn from_hsl( hue: ColorComponent<NumberOrAngle>, saturation: ColorComponent<NumberOrPercentage>, lightness: ColorComponent<NumberOrPercentage>, alpha: ColorComponent<NumberOrPercentage> ) -> Self
Construct a new color from hue, saturation, lightness and alpha components.
source§fn from_hwb(
hue: ColorComponent<NumberOrAngle>,
whiteness: ColorComponent<NumberOrPercentage>,
blackness: ColorComponent<NumberOrPercentage>,
alpha: ColorComponent<NumberOrPercentage>
) -> Self
fn from_hwb( hue: ColorComponent<NumberOrAngle>, whiteness: ColorComponent<NumberOrPercentage>, blackness: ColorComponent<NumberOrPercentage>, alpha: ColorComponent<NumberOrPercentage> ) -> Self
Construct a new color from hue, blackness, whiteness and alpha components.
source§fn from_lab(
lightness: ColorComponent<NumberOrPercentage>,
a: ColorComponent<NumberOrPercentage>,
b: ColorComponent<NumberOrPercentage>,
alpha: ColorComponent<NumberOrPercentage>
) -> Self
fn from_lab( lightness: ColorComponent<NumberOrPercentage>, a: ColorComponent<NumberOrPercentage>, b: ColorComponent<NumberOrPercentage>, alpha: ColorComponent<NumberOrPercentage> ) -> Self
Construct a new color from the
lab
notation.source§fn from_lch(
lightness: ColorComponent<NumberOrPercentage>,
chroma: ColorComponent<NumberOrPercentage>,
hue: ColorComponent<NumberOrAngle>,
alpha: ColorComponent<NumberOrPercentage>
) -> Self
fn from_lch( lightness: ColorComponent<NumberOrPercentage>, chroma: ColorComponent<NumberOrPercentage>, hue: ColorComponent<NumberOrAngle>, alpha: ColorComponent<NumberOrPercentage> ) -> Self
Construct a new color from the
lch
notation.source§fn from_oklab(
lightness: ColorComponent<NumberOrPercentage>,
a: ColorComponent<NumberOrPercentage>,
b: ColorComponent<NumberOrPercentage>,
alpha: ColorComponent<NumberOrPercentage>
) -> Self
fn from_oklab( lightness: ColorComponent<NumberOrPercentage>, a: ColorComponent<NumberOrPercentage>, b: ColorComponent<NumberOrPercentage>, alpha: ColorComponent<NumberOrPercentage> ) -> Self
Construct a new color from the
oklab
notation.source§fn from_oklch(
lightness: ColorComponent<NumberOrPercentage>,
chroma: ColorComponent<NumberOrPercentage>,
hue: ColorComponent<NumberOrAngle>,
alpha: ColorComponent<NumberOrPercentage>
) -> Self
fn from_oklch( lightness: ColorComponent<NumberOrPercentage>, chroma: ColorComponent<NumberOrPercentage>, hue: ColorComponent<NumberOrAngle>, alpha: ColorComponent<NumberOrPercentage> ) -> Self
Construct a new color from the
oklch
notation.source§fn from_color_function(
color_space: PredefinedColorSpace,
c1: ColorComponent<NumberOrPercentage>,
c2: ColorComponent<NumberOrPercentage>,
c3: ColorComponent<NumberOrPercentage>,
alpha: ColorComponent<NumberOrPercentage>
) -> Self
fn from_color_function( color_space: PredefinedColorSpace, c1: ColorComponent<NumberOrPercentage>, c2: ColorComponent<NumberOrPercentage>, c3: ColorComponent<NumberOrPercentage>, alpha: ColorComponent<NumberOrPercentage> ) -> Self
Construct a new color with a predefined color space.
source§impl MallocSizeOf for Color
impl MallocSizeOf for Color
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
source§impl Parse for Color
impl Parse for Color
source§fn parse<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>>
fn parse<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't> ) -> Result<Self, ParseError<'i>>
Parse a value of this type. Read more
source§impl PartialEq<Color> for Color
impl PartialEq<Color> for Color
source§impl SpecifiedValueInfo for Color
impl SpecifiedValueInfo for Color
source§const SUPPORTED_TYPES: u8 = 1u8
const SUPPORTED_TYPES: u8 = 1u8
Supported CssTypes by the given value type. Read more
source§fn collect_completion_keywords(f: KeywordsCollectFn<'_>)
fn collect_completion_keywords(f: KeywordsCollectFn<'_>)
Collect value starting words for the given specified value type.
This includes keyword and function names which can appear at the
beginning of a value of this type. Read more
source§impl ToComputedValue for Color
impl ToComputedValue for Color
§type ComputedValue = GenericColor<Percentage>
type ComputedValue = GenericColor<Percentage>
The computed value type we’re going to be converted to.
source§fn to_computed_value(&self, context: &Context<'_>) -> ComputedColor
fn to_computed_value(&self, context: &Context<'_>) -> ComputedColor
Convert a specified value to a computed value, using itself and the data
inside the
Context
.source§fn from_computed_value(computed: &ComputedColor) -> Self
fn from_computed_value(computed: &ComputedColor) -> Self
Convert a computed value to specified value form. Read more
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where F: FnOnce(&Self) -> bool,
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> MaybeBoxed<Box<T, Global>> for T
impl<T> MaybeBoxed<Box<T, Global>> for T
source§fn maybe_boxed(self) -> Box<T, Global>
fn maybe_boxed(self) -> Box<T, Global>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert