1use std::{fmt::Debug, sync::Arc};
2
3use ecolor::Color32;
4use emath::{Pos2, Rect};
5
6#[derive(Clone)]
8#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
9pub enum ColorMode {
10 Solid(Color32),
12
13 #[cfg_attr(feature = "serde", serde(skip))]
18 UV(Arc<dyn Fn(Rect, Pos2) -> Color32 + Send + Sync>),
19}
20
21impl Default for ColorMode {
22 fn default() -> Self {
23 Self::Solid(Color32::TRANSPARENT)
24 }
25}
26
27impl Debug for ColorMode {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 match self {
30 Self::Solid(arg0) => f.debug_tuple("Solid").field(arg0).finish(),
31 Self::UV(_arg0) => f.debug_tuple("UV").field(&"<closure>").finish(),
32 }
33 }
34}
35
36impl PartialEq for ColorMode {
37 fn eq(&self, other: &Self) -> bool {
38 match (self, other) {
39 (Self::Solid(l0), Self::Solid(r0)) => l0 == r0,
40 (Self::UV(_l0), Self::UV(_r0)) => false,
41 _ => false,
42 }
43 }
44}
45
46impl ColorMode {
47 pub const TRANSPARENT: Self = Self::Solid(Color32::TRANSPARENT);
48}