@@ -3,6 +3,9 @@ use super::ShapeStyle;
33
44use plotters_backend:: { BackendColor , BackendStyle } ;
55
6+ #[ cfg( feature = "serialization" ) ]
7+ use serde:: { Deserialize , Serialize } ;
8+
69use std:: marker:: PhantomData ;
710
811/// Any color representation
@@ -64,6 +67,7 @@ impl<T: Color> Color for &'_ T {
6467///
6568/// If you want to directly create a RGB color with transparency use [RGBColor::mix]
6669#[ derive( Copy , Clone , PartialEq , Debug , Default ) ]
70+ #[ cfg_attr( feature = "serialization" , derive( Serialize , Deserialize ) ) ]
6771pub struct RGBAColor ( pub u8 , pub u8 , pub u8 , pub f64 ) ;
6872
6973impl Color for RGBAColor {
@@ -84,6 +88,7 @@ impl From<RGBColor> for RGBAColor {
8488
8589/// A color in the given palette
8690#[ derive( Copy , Clone , Eq , PartialEq , Hash , Debug , Default ) ]
91+ #[ cfg_attr( feature = "serialization" , derive( Serialize , Deserialize ) ) ]
8792pub struct PaletteColor < P : Palette > ( usize , PhantomData < P > ) ;
8893
8994impl < P : Palette > PaletteColor < P > {
@@ -105,6 +110,7 @@ impl<P: Palette> Color for PaletteColor<P> {
105110
106111/// The color described by its RGB value
107112#[ derive( Copy , Clone , Eq , PartialEq , Hash , Debug , Default ) ]
113+ #[ cfg_attr( feature = "serialization" , derive( Serialize , Deserialize ) ) ]
108114pub struct RGBColor ( pub u8 , pub u8 , pub u8 ) ;
109115
110116impl BackendStyle for RGBAColor {
@@ -130,6 +136,7 @@ impl BackendStyle for RGBColor {
130136
131137/// The color described by HSL color space
132138#[ derive( Copy , Clone , PartialEq , Debug , Default ) ]
139+ #[ cfg_attr( feature = "serialization" , derive( Serialize , Deserialize ) ) ]
133140pub struct HSLColor ( pub f64 , pub f64 , pub f64 ) ;
134141
135142impl Color for HSLColor {
0 commit comments