use std::{fmt::Debug, sync::Arc};
use ecolor::Color32;
use emath::{Pos2, Rect};
#[derive(Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum ColorMode {
Solid(Color32),
#[cfg_attr(feature = "serde", serde(skip))]
UV(Arc<dyn Fn(Rect, Pos2) -> Color32 + Send + Sync>),
}
impl Default for ColorMode {
fn default() -> Self {
Self::Solid(Color32::TRANSPARENT)
}
}
impl Debug for ColorMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Solid(arg0) => f.debug_tuple("Solid").field(arg0).finish(),
Self::UV(_arg0) => f.debug_tuple("UV").field(&"<closure>").finish(),
}
}
}
impl PartialEq for ColorMode {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Solid(l0), Self::Solid(r0)) => l0 == r0,
(Self::UV(_l0), Self::UV(_r0)) => false,
_ => false,
}
}
}
impl ColorMode {
pub const TRANSPARENT: Self = Self::Solid(Color32::TRANSPARENT);
}