Skip to main content

primitives/foundation/colorspace/
cmy.rs

1use super::*;
2use std::fmt;
3
4/// Cmy color representation
5#[derive(Clone, Copy, PartialEq, Debug)]
6pub struct CmyColor {
7    /// Cyan component
8    pub cyan: Float,
9    /// Magenta component
10    pub magenta: Float,
11    /// Yellow component
12    pub yellow: Float,
13}
14
15impl fmt::Display for CmyColor {
16    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17        write!(
18            f,
19            "cmy({}%, {}%, {}%)",
20            self.cyan, self.magenta, self.yellow
21        )
22    }
23}
24
25impl CmyColor {
26    /// Create new Cmy color with parameters
27    pub fn new(cyan: Float, magenta: Float, yellow: Float) -> Self {
28        Self {
29            cyan,
30            magenta,
31            yellow,
32        }
33    }
34}
35
36// CMY -> RGB
37impl From<CmyColor> for Color {
38    fn from(_: CmyColor) -> Self {
39        // TODO: implement CMY -> RGB
40        unimplemented!("{}: CMY -> RGB", ColorError::Unimplemented);
41    }
42}
43
44// RGB -> CMY
45impl From<Color> for CmyColor {
46    fn from(_: Color) -> Self {
47        // TODO: implement RGB -> CMY
48        unimplemented!("{}: RGB -> CMY", ColorError::Unimplemented);
49    }
50}