| 1 |
|
| 2 |
use super::{RGBAColor, RGBColor}; |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#[macro_export] |
| 7 |
macro_rules! doc { |
| 8 |
{ |
| 9 |
$(#[$m:meta])* |
| 10 |
$( |
| 11 |
[$doc:expr] |
| 12 |
$(#[$n:meta])* |
| 13 |
)* |
| 14 |
@ $thing:item |
| 15 |
} => { |
| 16 |
$(#[$m])* |
| 17 |
$( |
| 18 |
#[doc = $doc] |
| 19 |
$(#[$n])* |
| 20 |
)* |
| 21 |
$thing |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
#[macro_export] |
| 27 |
macro_rules! define_color { |
| 28 |
($name:ident, $r:expr, $g:expr, $b:expr, $doc:expr) => { |
| 29 |
doc! { |
| 30 |
[$doc] |
| 31 |
|
| 32 |
[concat!("(<span style='color: rgb(", $r,",", $g, ",", $b, "); background-color: #ddd; padding: 0 0.2em;'>■</span>" )] |
| 33 |
[concat!("*rgb = (", $r,", ", $g, ", ", $b, ")*)")] |
| 34 |
@pub const $name: RGBColor = RGBColor($r, $g, $b); |
| 35 |
} |
| 36 |
}; |
| 37 |
|
| 38 |
($name:ident, $r:expr, $g:expr, $b:expr, $a: expr, $doc:expr) => { |
| 39 |
doc! { |
| 40 |
[$doc] |
| 41 |
|
| 42 |
[concat!("(<span style='color: rgba(", $r,",", $g, ",", $b, ",", $a, "); background-color: #ddd; padding: 0 0.2em;'>■</span>" )] |
| 43 |
[concat!("*rgba = (", $r,", ", $g, ", ", $b, ", ", $a, ")*)")] |
| 44 |
@pub const $name: RGBAColor = RGBAColor($r, $g, $b, $a); |
| 45 |
} |
| 46 |
}; |
| 47 |
} |
| 48 |
|
| 49 |
define_color!(WHITE, 255, 255, 255, "White"); |
| 50 |
define_color!(BLACK, 0, 0, 0, "Black"); |
| 51 |
define_color!(RED, 255, 0, 0, "Red"); |
| 52 |
define_color!(GREEN, 0, 255, 0, "Green"); |
| 53 |
define_color!(BLUE, 0, 0, 255, "Blue"); |
| 54 |
define_color!(YELLOW, 255, 255, 0, "Yellow"); |
| 55 |
define_color!(CYAN, 0, 255, 255, "Cyan"); |
| 56 |
define_color!(MAGENTA, 255, 0, 255, "Magenta"); |
| 57 |
define_color!(TRANSPARENT, 0, 0, 0, 0.0, "Transparent"); |
| 58 |
|
| 59 |
#[cfg(feature = "colormaps")] |
| 60 |
#[cfg_attr(doc_cfg, doc(cfg(feature = "colormaps")))] |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
pub mod colormaps; |
| 65 |
#[cfg(feature = "full_palette")] |
| 66 |
#[cfg_attr(doc_cfg, doc(cfg(feature = "full_palette")))] |
| 67 |
pub mod full_palette; |