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
impl AbsoluteColor
sourcefn carry_forward_analogous_missing_components(&mut self, source: &AbsoluteColor)
fn carry_forward_analogous_missing_components(&mut self, source: &AbsoluteColor)
Calculate the flags that should be carried forward a color before converting it to the interpolation color space according to: https://drafts.csswg.org/css-color-4/#interpolation-missing
source§impl AbsoluteColor
impl AbsoluteColor
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
impl AbsoluteColor
sourcepub const TRANSPARENT_BLACK: Self = _
pub const TRANSPARENT_BLACK: Self = _
A fully transparent color in the legacy syntax.
sourcepub fn new(
color_space: ColorSpace,
c1: impl Into<ComponentDetails>,
c2: impl Into<ComponentDetails>,
c3: impl Into<ComponentDetails>,
alpha: impl Into<ComponentDetails>,
) -> Self
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.
sourcepub fn into_srgb_legacy(self) -> Self
pub fn into_srgb_legacy(self) -> Self
Convert this color into the sRGB color space and set it to the legacy syntax.
sourcepub fn srgb_legacy(red: u8, green: u8, blue: u8, alpha: f32) -> Self
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.
sourcepub fn raw_components(&self) -> &[f32; 4]
pub fn raw_components(&self) -> &[f32; 4]
Return all the components of the color in an array. (Includes alpha)
sourcepub fn is_legacy_syntax(&self) -> bool
pub fn is_legacy_syntax(&self) -> bool
Returns true if this color is in the legacy color syntax.
sourcepub fn is_transparent(&self) -> bool
pub fn is_transparent(&self) -> bool
Returns true if this color is fully transparent.
sourcepub fn get_component_by_channel_keyword(
&self,
channel_keyword: ChannelKeyword,
) -> Result<Option<f32>, ()>
pub fn get_component_by_channel_keyword( &self, channel_keyword: ChannelKeyword, ) -> Result<Option<f32>, ()>
Return the value of a component by its channel keyword.
sourcepub fn to_color_space(&self, color_space: ColorSpace) -> Self
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
impl Animate for AbsoluteColor
source§impl Clone for AbsoluteColor
impl Clone for AbsoluteColor
source§fn clone(&self) -> AbsoluteColor
fn clone(&self) -> AbsoluteColor
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl ComputeSquaredDistance for AbsoluteColor
impl ComputeSquaredDistance for AbsoluteColor
source§fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()>
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()>
source§impl Debug for AbsoluteColor
impl Debug for AbsoluteColor
source§impl<'de> Deserialize<'de> for AbsoluteColor
impl<'de> Deserialize<'de> for AbsoluteColor
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<AbsoluteColor> for Color
impl From<AbsoluteColor> for Color
source§fn from(value: AbsoluteColor) -> Self
fn from(value: AbsoluteColor) -> Self
source§impl MallocSizeOf for AbsoluteColor
impl MallocSizeOf for AbsoluteColor
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl PartialEq for AbsoluteColor
impl PartialEq for AbsoluteColor
source§impl Serialize for AbsoluteColor
impl Serialize for AbsoluteColor
source§impl ToAnimatedValue for AbsoluteColor
impl ToAnimatedValue for AbsoluteColor
source§type AnimatedValue = AbsoluteColor
type AnimatedValue = AbsoluteColor
source§fn to_animated_value(self, _: &Context<'_>) -> Self
fn to_animated_value(self, _: &Context<'_>) -> Self
source§fn from_animated_value(animated: Self::AnimatedValue) -> Self
fn from_animated_value(animated: Self::AnimatedValue) -> Self
source§impl ToAnimatedZero for AbsoluteColor
impl ToAnimatedZero for AbsoluteColor
source§fn to_animated_zero(&self) -> Result<Self, ()>
fn to_animated_zero(&self) -> Result<Self, ()>
source§impl ToCss for AbsoluteColor
impl ToCss for AbsoluteColor
source§impl ToResolvedValue for AbsoluteColor
impl ToResolvedValue for AbsoluteColor
source§type ResolvedValue = AbsoluteColor
type ResolvedValue = AbsoluteColor
source§fn to_resolved_value(self, _: &Context<'_>) -> Self
fn to_resolved_value(self, _: &Context<'_>) -> Self
source§fn from_resolved_value(resolved: Self::ResolvedValue) -> Self
fn from_resolved_value(resolved: Self::ResolvedValue) -> Self
source§impl ToShmem for AbsoluteColor
impl ToShmem for AbsoluteColor
impl Copy for AbsoluteColor
impl StructuralPartialEq for AbsoluteColor
Auto Trait Implementations§
impl Freeze for AbsoluteColor
impl RefUnwindSafe for AbsoluteColor
impl Send for AbsoluteColor
impl Sync for AbsoluteColor
impl Unpin for AbsoluteColor
impl UnwindSafe for AbsoluteColor
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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>
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>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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