Struct colstodian::DynamicColor [−][src]
pub struct DynamicColor { pub raw: Vec3, pub space: DynamicColorSpace, pub state: DynamicState, }
Expand description
A dynamic color, with its Space and State defined as data. This is mostly useful for (de)serialization.
See Color
, ColorSpace
and State
for more.
Fields
raw: Vec3
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
state: DynamicState
Implementations
Create a new DynamicColor
with specified raw color components, color space, and state.
Convert self
to the given color space. Must not attempt to convert to or from
a nonlinear color space while in scene-referred state.
pub fn convert_state<F>(
self,
dest_state: DynamicState,
conversion: F
) -> ColorResult<Self> where
F: FnOnce(Vec3) -> Vec3,
pub fn convert_state<F>(
self,
dest_state: DynamicState,
conversion: F
) -> ColorResult<Self> where
F: FnOnce(Vec3) -> Vec3,
Convert self
’s state to the given state using the given conversion function.
self.space
must be linear. See docs for Color::<Space, State>::convert_state
pub fn downcast_convert<DstSpace, DstState>(
self
) -> ColorResult<Color<DstSpace, DstState>> where
DstSpace: ColorSpace,
DstState: State,
pub fn downcast_convert<DstSpace, DstState>(
self
) -> ColorResult<Color<DstSpace, DstState>> where
DstSpace: ColorSpace,
DstState: State,
Convert self
to the specified space and downcast it to a typed Color
with the space
and state specified. self
must already be in the correct DynamicState
Convert self
into the closest linear color space, if it is not linear already
Converts self
to a DynamicColorAlpha
with specified DynamicAlphaState
by adding an alpha component.
Trait Implementations
Upcasts self
into a DynamicColor
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.
Performs the conversion.
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 DynamicColor
impl Send for DynamicColor
impl Sync for DynamicColor
impl Unpin for DynamicColor
impl UnwindSafe for DynamicColor
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>,
pub fn downcast<Spc, St>(&Self) -> Result<Color<Spc, St>, ColorError> where
Spc: ColorSpace,
St: State,
pub fn downcast<Spc, St>(&Self) -> Result<Color<Spc, St>, ColorError> where
Spc: ColorSpace,
St: State,
Attempt to convert to a typed Color
. Returns an error if self
’s color space and state do not match
the given types.
Convert to a typed Color
without checking if the color space and state types
match this color’s space and state. Use only if you are sure that this color
is in the correct format.