Enum style::color::ColorSpace

source ·
#[repr(u8)]
pub enum ColorSpace {
Show 14 variants Srgb = 0, Hsl = 1, Hwb = 2, Lab = 3, Lch = 4, Oklab = 5, Oklch = 6, SrgbLinear = 7, DisplayP3 = 8, A98Rgb = 9, ProphotoRgb = 10, Rec2020 = 11, XyzD50 = 12, XyzD65 = 13,
}
Expand description

A color space representation in the CSS specification.

https://drafts.csswg.org/css-color-4/#typedef-color-space

Variants§

§

Srgb = 0

A color specified in the sRGB color space with either the rgb/rgba(..) functions or the newer color(srgb ..) function. If the color(..) function is used, the AS_COLOR_FUNCTION flag will be set. Examples: “color(srgb 0.691 0.139 0.259)”, “rgb(176, 35, 66)”

§

Hsl = 1

A color specified in the Hsl notation in the sRGB color space, e.g. “hsl(289.18 93.136% 65.531%)” https://drafts.csswg.org/css-color-4/#the-hsl-notation

§

Hwb = 2

A color specified in the Hwb notation in the sRGB color space, e.g. “hwb(740deg 20% 30%)” https://drafts.csswg.org/css-color-4/#the-hwb-notation

§

Lab = 3

A color specified in the Lab color format, e.g. “lab(29.2345% 39.3825 20.0664)”. https://w3c.github.io/csswg-drafts/css-color-4/#lab-colors

§

Lch = 4

A color specified in the Lch color format, e.g. “lch(29.2345% 44.2 27)”. https://w3c.github.io/csswg-drafts/css-color-4/#lch-colors

§

Oklab = 5

A color specified in the Oklab color format, e.g. “oklab(40.101% 0.1147 0.0453)”. https://w3c.github.io/csswg-drafts/css-color-4/#lab-colors

§

Oklch = 6

A color specified in the Oklch color format, e.g. “oklch(40.101% 0.12332 21.555)”. https://w3c.github.io/csswg-drafts/css-color-4/#lch-colors

§

SrgbLinear = 7

A color specified with the color(..) function and the “srgb-linear” color space, e.g. “color(srgb-linear 0.435 0.017 0.055)”.

§

DisplayP3 = 8

A color specified with the color(..) function and the “display-p3” color space, e.g. “color(display-p3 0.84 0.19 0.72)”.

§

A98Rgb = 9

A color specified with the color(..) function and the “a98-rgb” color space, e.g. “color(a98-rgb 0.44091 0.49971 0.37408)”.

§

ProphotoRgb = 10

A color specified with the color(..) function and the “prophoto-rgb” color space, e.g. “color(prophoto-rgb 0.36589 0.41717 0.31333)”.

§

Rec2020 = 11

A color specified with the color(..) function and the “rec2020” color space, e.g. “color(rec2020 0.42210 0.47580 0.35605)”.

§

XyzD50 = 12

A color specified with the color(..) function and the “xyz-d50” color space, e.g. “color(xyz-d50 0.2005 0.14089 0.4472)”.

§

XyzD65 = 13

A color specified with the color(..) function and the “xyz-d65” or “xyz” color space, e.g. “color(xyz-d65 0.21661 0.14602 0.59452)”. NOTE: https://drafts.csswg.org/css-color-4/#resolving-color-function-values specifies that xyz is an alias for the xyz-d65 color space.

Implementations§

source§

impl ColorSpace

source

pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>>

Parse this keyword.

source

pub fn from_ident(ident: &str) -> Result<Self, ()>

Parse this keyword from a string slice.

source§

impl ColorSpace

source

pub fn is_rectangular(&self) -> bool

Returns whether this is a <rectangular-color-space>.

source

pub fn is_polar(&self) -> bool

Returns whether this is a <polar-color-space>.

source

pub fn is_rgb_or_xyz_like(&self) -> bool

Returns true if the color has RGB or XYZ components.

source

pub fn hue_index(&self) -> Option<usize>

Returns an index of the hue component in the color space, otherwise None.

Trait Implementations§

source§

impl Clone for ColorSpace

source§

fn clone(&self) -> ColorSpace

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ColorSpace

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for ColorSpace

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<PredefinedColorSpace> for ColorSpace

source§

fn from(value: PredefinedColorSpace) -> Self

Converts to this type from the input type.
source§

impl MallocSizeOf for ColorSpace

source§

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 ColorSpace

source§

fn parse<'i, 't>( _: &ParserContext<'_>, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>>

Parse a value of this type. Read more
source§

impl PartialEq for ColorSpace

source§

fn eq(&self, other: &ColorSpace) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for ColorSpace

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ToAnimatedValue for ColorSpace

§

type AnimatedValue = ColorSpace

The type of the animated value.
source§

fn from_animated_value(from: Self::AnimatedValue) -> Self

Converts back an animated value into a computed value.
source§

fn to_animated_value(self, context: &Context<'_>) -> Self::AnimatedValue

Converts this value to an animated value.
source§

impl ToComputedValue for ColorSpace

§

type ComputedValue = ColorSpace

The computed value type we’re going to be converted to.
source§

fn from_computed_value(from: &Self::ComputedValue) -> Self

Convert a computed value to specified value form. Read more
source§

fn to_computed_value(&self, context: &Context<'_>) -> Self::ComputedValue

Convert a specified value to a computed value, using itself and the data inside the Context.
source§

impl ToCss for ColorSpace

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§

impl ToResolvedValue for ColorSpace

§

type ResolvedValue = ColorSpace

The resolved value type we’re going to be converted to.
source§

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

Convert a resolved value to resolved value form.
source§

fn to_resolved_value(self, context: &Context<'_>) -> Self::ResolvedValue

Convert a resolved value to a resolved value.
source§

impl ToShmem for ColorSpace

source§

fn to_shmem(&self, builder: &mut SharedMemoryBuilder) -> Result<Self>

Clones this value into a form suitable for writing into a SharedMemoryBuilder. Read more
source§

impl Copy for ColorSpace

source§

impl Eq for ColorSpace

source§

impl StructuralPartialEq for ColorSpace

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

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 more
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T