Struct colstodian::DynamicColorAlpha [−][src]
pub struct DynamicColorAlpha { pub raw: Vec4, pub space: DynamicColorSpace, pub alpha_state: DynamicAlphaState, }
Expand description
A dynamic color with an alpha channel, with its space and alpha defined as data. This is mostly useful for (de)serialization.
See ColorAlpha
, ColorSpace
and AlphaState
for more.
Fields
raw: Vec4
The raw tristimulus value of the color. Be careful when modifying this directly, i.e. don’t multiply two Colors’ raw values unless they are in the same color space and state.
space: DynamicColorSpace
alpha_state: DynamicAlphaState
Implementations
Create a new DynamicColorAlpha
with specified raw color components, color space, and alpha state.
Converts self
to a DynamicColor
by first premultiplying self
if it is not already
and then stripping off the alpha component.
Converts self
to a DynamicColor
by stripping off the alpha component, without checking
whether it is premultiplied or not.
Converts from one color space and state to another.
- If converting from Premultiplied to Separate, if
self
’s alpha is 0.0, the resulting color values will not be changed.
pub fn downcast_convert<DstSpace, DstAlpha>(
self
) -> ColorAlpha<DstSpace, DstAlpha> where
DstSpace: ColorSpace,
DstAlpha: AlphaState,
pub fn downcast_convert<DstSpace, DstAlpha>(
self
) -> ColorAlpha<DstSpace, DstAlpha> where
DstSpace: ColorSpace,
DstAlpha: AlphaState,
Convert self
to the specified space and downcast it to a typed ColorAlpha
with the space
and state specified.
Converts self
to the provided dst_alpha
DynamicAlphaState
.
- If converting to the same state, this is a no-op.
- If converting from Premultiplied to Separate, if
self
’s alpha is 0.0, the resulting color values will not be changed.
Trait Implementations
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>,
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for DynamicColorAlpha
impl Send for DynamicColorAlpha
impl Sync for DynamicColorAlpha
impl Unpin for DynamicColorAlpha
impl UnwindSafe for DynamicColorAlpha
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<SrcAlpha, DstAlpha> ConvertToAlphaRaw<DstAlpha> for SrcAlpha where
DstAlpha: ConvertFromAlphaRaw<SrcAlpha>,
impl<SrcAlpha, DstAlpha> ConvertToAlphaRaw<DstAlpha> for SrcAlpha where
DstAlpha: ConvertFromAlphaRaw<SrcAlpha>,