color4.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "vec4.h"
5 #include "color3.h"
6 
7 
8 namespace ion
9 {
10 
13  template <typename T>
14  class color4 : public vec4<T>
15  {
16 
17  public:
18 
19  T & Red, & Green, & Blue, & Alpha;
20 
23  : Red(this->X), Green(this->Y), Blue(this->Z), Alpha(this->W), vec4<T>()
24  {}
25 
27  color4(T const in)
28  : Red(this->X), Green(this->Y), Blue(this->Z), Alpha(this->W), vec4<T>(in)
29  {}
30 
32  color4(T const r, T const g, T const b, T const a)
33  : Red(this->X), Green(this->Y), Blue(this->Z), Alpha(this->W), vec4<T>(r, g, b, a)
34  {}
35 
37  color4(color4<T> const & Other)
38  : Red(this->X), Green(this->Y), Blue(this->Z), Alpha(this->W), vec4<T>(Other)
39  {}
40 
42  color4(vec4<T> const & Other)
43  : Red(this->X), Green(this->Y), Blue(this->Z), Alpha(this->W), vec4<T>(Other)
44  {}
45 
47  template <typename U>
48  color4(color4<U> const & Other)
49  : Red(this->X), Green(this->Y), Blue(this->Z), Alpha(this->W), vec4<T>()
50  {
51  Red = Color::Convert<T, U>::From(Other.Red);
52  Green = Color::Convert<T, U>::From(Other.Green);
53  Blue = Color::Convert<T, U>::From(Other.Blue);
54  Alpha = Color::Convert<T, U>::From(Other.Alpha);
55  }
56 
58  color4<T> & operator = (color4<T> const & Other)
59  {
60  Red = Other.Red;
61  Green = Other.Green;
62  Blue = Other.Blue;
63  Alpha = Other.Alpha;
64  return * this;
65  }
66 
68  template <typename U>
69  color4<T> & operator = (color4<U> const & Other)
70  {
71  Red = Color::Convert<T, U>::From(Other.Red);
72  Green = Color::Convert<T, U>::From(Other.Green);
73  Blue = Color::Convert<T, U>::From(Other.Blue);
74  Alpha = Color::Convert<T, U>::From(Other.Alpha);
75  return *this;
76  }
77 
79  color4(color3<T> const & Other)
80  : Red(this->X), Green(this->Y), Blue(this->Z), Alpha(this->W), vec4<T>(Other)
81  {
82  Alpha = Color::Full<T>::Value();
83  }
84 
86  template <typename U>
87  color4(color3<U> const & Other)
88  : Red(this->X), Green(this->Y), Blue(this->Z), Alpha(this->W), vec4<T>()
89  {
90  Red = Color::Convert<T, U>::From(Other.Red);
91  Green = Color::Convert<T, U>::From(Other.Green);
92  Blue = Color::Convert<T, U>::From(Other.Blue);
93  Alpha = Color::Full<T>::Value();
94  }
95 
98  {
99  Red = col.Red;
100  Green = col.Green;
101  Blue = col.Blue;
102  Alpha = Color::Full<T>::Value();
103 
104  return * this;
105  }
106 
108  template <typename U>
110  {
111  Red = Color::Convert<T, U>::From(col.Red);
112  Green = Color::Convert<T, U>::From(col.Green);
113  Blue = Color::Convert<T, U>::From(col.Blue);
114  Alpha = Color::Full<T>::Value();
115 
116  return * this;
117  }
118 
119  operator color3<T>()
120  {
121  color3<T> ret;
122  ret.Red = Red;
123  ret.Green = Green;
124  ret.Blue = Blue;
125  return ret;
126  }
127 
128  };
129 
132 
133 }
T Y
Definition: vec4.h:20
T & Alpha
Definition: color4.h:19
T X
Definition: vec4.h:19
color4(T const in)
Scalar constructor.
Definition: color4.h:27
4D vector
Definition: vec4.h:14
color4< byte > color4i
Definition: color4.h:130
color4(color4< T > const &Other)
Copy constructor.
Definition: color4.h:37
T & Blue
Definition: color4.h:19
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
color4(color3< U > const &Other)
Generic color3 constructor.
Definition: color4.h:87
color4< T > & operator=(color4< T > const &Other)
Copy assignment operator.
Definition: color4.h:58
color4(vec4< T > const &Other)
Vector copy constructor.
Definition: color4.h:42
Determines the maximum color value for a given type.
Definition: color3.h:17
T & Green
Definition: color3.h:72
Customized variant of vec4 that intelligently handles conversion between floating point and integer c...
Definition: color4.h:14
Implements a conversion between two color types.
Definition: color3.h:41
T Z
Definition: vec4.h:21
color4(color4< U > const &Other)
Generic copy constructor.
Definition: color4.h:48
color4(color3< T > const &Other)
color3 constructor
Definition: color4.h:79
T W
Definition: vec4.h:22
Customized variant of vec3 that intelligently handles conversion between floating point and integer c...
Definition: color3.h:67
T & Red
Definition: color3.h:72
color4< float > color4f
Definition: color4.h:131
T & Green
Definition: color4.h:19
color4(T const r, T const g, T const b, T const a)
Explicit constructor.
Definition: color4.h:32
T & Blue
Definition: color3.h:72
T & Red
Definition: color4.h:19
color4()
Default constructor.
Definition: color4.h:22