@@ -3,6 +3,9 @@ use super::ShapeStyle;
3
3
4
4
use plotters_backend:: { BackendColor , BackendStyle } ;
5
5
6
+ #[ cfg( feature = "serialization" ) ]
7
+ use serde:: { Deserialize , Serialize } ;
8
+
6
9
use std:: marker:: PhantomData ;
7
10
8
11
/// Any color representation
@@ -64,6 +67,7 @@ impl<T: Color> Color for &'_ T {
64
67
///
65
68
/// If you want to directly create a RGB color with transparency use [RGBColor::mix]
66
69
#[ derive( Copy , Clone , PartialEq , Debug , Default ) ]
70
+ #[ cfg_attr( feature = "serialization" , derive( Serialize , Deserialize ) ) ]
67
71
pub struct RGBAColor ( pub u8 , pub u8 , pub u8 , pub f64 ) ;
68
72
69
73
impl Color for RGBAColor {
@@ -84,6 +88,7 @@ impl From<RGBColor> for RGBAColor {
84
88
85
89
/// A color in the given palette
86
90
#[ derive( Copy , Clone , Eq , PartialEq , Hash , Debug , Default ) ]
91
+ #[ cfg_attr( feature = "serialization" , derive( Serialize , Deserialize ) ) ]
87
92
pub struct PaletteColor < P : Palette > ( usize , PhantomData < P > ) ;
88
93
89
94
impl < P : Palette > PaletteColor < P > {
@@ -105,6 +110,7 @@ impl<P: Palette> Color for PaletteColor<P> {
105
110
106
111
/// The color described by its RGB value
107
112
#[ derive( Copy , Clone , Eq , PartialEq , Hash , Debug , Default ) ]
113
+ #[ cfg_attr( feature = "serialization" , derive( Serialize , Deserialize ) ) ]
108
114
pub struct RGBColor ( pub u8 , pub u8 , pub u8 ) ;
109
115
110
116
impl BackendStyle for RGBAColor {
@@ -130,6 +136,7 @@ impl BackendStyle for RGBColor {
130
136
131
137
/// The color described by HSL color space
132
138
#[ derive( Copy , Clone , PartialEq , Debug , Default ) ]
139
+ #[ cfg_attr( feature = "serialization" , derive( Serialize , Deserialize ) ) ]
133
140
pub struct HSLColor ( pub f64 , pub f64 , pub f64 ) ;
134
141
135
142
impl Color for HSLColor {
0 commit comments