Conversion traits for palette::Srgb
This commit is contained in:
parent
ea3b7b5282
commit
04be010fbd
@ -1,5 +1,5 @@
|
||||
#[cfg(feature = "palette")]
|
||||
use palette::rgb::Srgba;
|
||||
use palette::rgb::{Srgb, Srgba};
|
||||
|
||||
/// A color in the sRGB color space.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||
@ -163,6 +163,28 @@ impl From<Color> for Srgba {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "palette")]
|
||||
/// Convert from palette's [`Srgb`] type to a [`Color`]
|
||||
///
|
||||
/// [`Srgb`]: ../palette/rgb/type.Srgb.html
|
||||
/// [`Color`]: struct.Color.html
|
||||
impl From<Srgb> for Color {
|
||||
fn from(srgb: Srgb) -> Self {
|
||||
Color::new(srgb.red, srgb.green, srgb.blue, 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "palette")]
|
||||
/// Convert from [`Color`] to palette's [`Srgb`] type
|
||||
///
|
||||
/// [`Color`]: struct.Color.html
|
||||
/// [`Srgb`]: ../palette/rgb/type.Srgb.html
|
||||
impl From<Color> for Srgb {
|
||||
fn from(c: Color) -> Self {
|
||||
Srgb::new(c.r, c.g, c.b)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "palette")]
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
Loading…
Reference in New Issue
Block a user