zm_test/
lib.rs

1//! # Art
2//!
3//! A library for modeling artistic concepts
4pub mod kinds {
5    /// The primary colors according to the RYB color model.
6    pub enum PrimaryColor {
7        Red,
8        Yellow,
9        Blue,
10    }
11
12    /// The secondary colors according to the RYB color model.
13    #[derive(Debug)]
14    pub enum SecondaryColor{
15        Orange,
16        Green,
17        Purple,
18    }
19}
20
21pub mod utils {
22    use crate::kinds::*;
23    /// Combines two primary colors in equal amounts to create
24    /// a secondary color.
25    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor{
26         match (c1, c2) {
27                (PrimaryColor::Red, PrimaryColor::Yellow) |
28                (PrimaryColor::Yellow, PrimaryColor::Red) => SecondaryColor::Orange,
29                (PrimaryColor::Red, PrimaryColor::Blue) |
30                (PrimaryColor::Blue, PrimaryColor::Red) => SecondaryColor::Purple,
31                (PrimaryColor::Yellow, PrimaryColor::Blue) |
32                (PrimaryColor::Blue, PrimaryColor::Yellow) => SecondaryColor::Green,
33                (_, _) => SecondaryColor::Purple,
34         }
35    }
36}