1pub( crate ) mod private
3{
4 use crate::protected::*;
5 use num_traits::{ Zero }; pub trait RgbaInterface< T >
9 where
10 T : Zero + fmt::Debug + Clone + Copy,
11 {
12 fn into_rgba( self ) -> Rgba< T >;
14 }
15
16 #[ derive( Debug, Clone ) ]
20 pub struct Rgba< T = f32 >
21 where
22 T : Zero + fmt::Debug + Clone + Copy,
23 {
24 pub r : T,
26 pub g : T,
28 pub b : T,
30 pub a : T,
32 }
33
34 impl< T > Default for Rgba< T >
35 where
36 T : Zero + fmt::Debug + Clone + Copy,
37 {
38 fn default() -> Self
39 {
40 Self
41 {
42 r : Zero::zero(),
43 g : Zero::zero(),
44 b : Zero::zero(),
45 a : Zero::zero(),
46 }
47 }
48 }
49
50 impl< T > RgbaInterface< T > for Rgba< T >
51 where
52 T : Zero + fmt::Debug + Clone + Copy,
53 {
54 fn into_rgba( self ) -> Rgba< T >
55 {
56 self
57 }
58 }
59
60 impl RgbaInterface< f32 >
61 for [ f32 ; 3 ]
62 {
63 fn into_rgba( self ) -> Rgba< f32 >
64 {
65 Rgba::< f32 >
66 {
67 r : self[ 0 ],
68 g : self[ 1 ],
69 b : self[ 2 ],
70 a : 1.0,
71 }
72 }
73 }
74
75 impl RgbaInterface< f32 >
76 for [ f32 ; 4 ]
77 {
78 fn into_rgba( self ) -> Rgba< f32 >
79 {
80 Rgba::< f32 >
81 {
82 r : self[ 0 ],
83 g : self[ 1 ],
84 b : self[ 2 ],
85 a : self[ 3 ],
86 }
87 }
88 }
89
90}
91
92crate::mod_interface!
93{
94
95 protected use ::rgb::*;
96
97 #[ cfg( feature = "use_std" ) ]
98 exposed use Rgba;
99
100 #[ cfg( feature = "use_std" ) ]
101 prelude use RgbaInterface;
102
103}