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