use crate::types::Color;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Module {
Empty,
Masked(Color),
Unmasked(Color),
}
impl From<Module> for Color {
fn from(module: Module) -> Self {
match module {
Module::Empty => Self::Light,
Module::Masked(c) | Module::Unmasked(c) => c,
}
}
}
impl Module {
#[must_use]
pub fn is_dark(self) -> bool {
Color::from(self) == Color::Dark
}
#[must_use]
pub fn mask(self, should_invert: bool) -> Self {
match (self, should_invert) {
(Self::Empty, true) => Self::Masked(Color::Dark),
(Self::Empty, false) => Self::Masked(Color::Light),
(Self::Unmasked(c), true) => Self::Masked(!c),
(Self::Unmasked(c), false) | (Self::Masked(c), _) => Self::Masked(c),
}
}
}