Struct style::color::AbsoluteColor

source ·
#[repr(C)]
pub struct AbsoluteColor { pub components: ColorComponents, pub alpha: f32, pub color_space: ColorSpace, pub flags: ColorFlags, }
Expand description

An absolutely specified color, using either rgb(), rgba(), lab(), lch(), oklab(), oklch() or color().

Fields§

§components: ColorComponents

The 3 components that make up colors in any color space.

§alpha: f32

The alpha component of the color.

§color_space: ColorSpace

The current color space that the components represent.

§flags: ColorFlags

Extra flags used durring serialization of this color.

Implementations§

source§

impl AbsoluteColor

source

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

Write a string to dest that represents a color as an author would enter it. NOTE: The format of the output is NOT according to any specification, but makes assumptions about the best ways that authors would want to enter color values in style sheets, devtools, etc.

source§

impl AbsoluteColor

source

pub const TRANSPARENT_BLACK: Self = _

A fully transparent color in the legacy syntax.

source

pub const BLACK: Self = _

An opaque black color in the legacy syntax.

source

pub const WHITE: Self = _

An opaque white color in the legacy syntax.

source

pub fn new( color_space: ColorSpace, c1: impl Into<ComponentDetails>, c2: impl Into<ComponentDetails>, c3: impl Into<ComponentDetails>, alpha: impl Into<ComponentDetails>, ) -> Self

Create a new AbsoluteColor with the given ColorSpace and components.

source

pub fn into_srgb_legacy(self) -> Self

Convert this color into the sRGB color space and set it to the legacy syntax.

source

pub fn srgb_legacy(red: u8, green: u8, blue: u8, alpha: f32) -> Self

Create a new AbsoluteColor from rgba legacy syntax values in the sRGB color space.

source

pub fn raw_components(&self) -> &[f32; 4]

Return all the components of the color in an array. (Includes alpha)

source

pub fn is_legacy_syntax(&self) -> bool

Returns true if this color is in the legacy color syntax.

source

pub fn is_transparent(&self) -> bool

Returns true if this color is fully transparent.

source

pub fn c0(&self) -> Option<f32>

Return an optional first component.

source

pub fn c1(&self) -> Option<f32>

Return an optional second component.

source

pub fn c2(&self) -> Option<f32>

Return an optional second component.

source

pub fn alpha(&self) -> Option<f32>

Return an optional alpha component.

source

pub fn get_component_by_channel_keyword( &self, channel_keyword: ChannelKeyword, ) -> Result<Option<f32>, ()>

Return the value of a component by its channel keyword.

source

pub fn to_color_space(&self, color_space: ColorSpace) -> Self

Convert this color to the specified color space.

Trait Implementations§

source§

impl Animate for AbsoluteColor

source§

fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()>

Animate a value towards another one, given an animation procedure.
source§

impl Clone for AbsoluteColor

source§

fn clone(&self) -> AbsoluteColor

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 ComputeSquaredDistance for AbsoluteColor

source§

fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()>

Computes the squared distance between two animatable values.
source§

impl Debug for AbsoluteColor

source§

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

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

impl<'de> Deserialize<'de> for AbsoluteColor

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<AbsoluteColor> for Color

source§

fn from(value: AbsoluteColor) -> Self

Converts to this type from the input type.
source§

impl MallocSizeOf for AbsoluteColor

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 PartialEq for AbsoluteColor

source§

fn eq(&self, other: &AbsoluteColor) -> 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 AbsoluteColor

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 AbsoluteColor

§

type AnimatedValue = AbsoluteColor

The type of the animated value.
source§

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

Converts this value to an animated value.
source§

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

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

impl ToAnimatedZero for AbsoluteColor

source§

fn to_animated_zero(&self) -> Result<Self, ()>

Returns a value that, when added with an underlying value, will produce the underlying value. This is used for SMIL animation’s “by-animation” where SMIL first interpolates from the zero value to the ‘by’ value, and then adds the result to the underlying value. Read more
source§

impl ToCss for AbsoluteColor

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 AbsoluteColor

§

type ResolvedValue = AbsoluteColor

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

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

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

impl ToShmem for AbsoluteColor

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 AbsoluteColor

source§

impl StructuralPartialEq for AbsoluteColor

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<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