Free Electron
Color.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __math_Color_h__
8 #define __math_Color_h__
9 
10 
11 namespace fe
12 {
13 
14 //typedef Vector<4,Real> Color;
15 
16 /**************************************************************************//**
17  @brief Special vector for color (RGBA)
18 
19  @ingroup math
20 *//***************************************************************************/
21 class Color: public Vector<4,Real>
22 {
23  public:
24  Color(void):
25  Vector<4,Real>() {}
26 
27  Color(Real r,Real g,Real b=(Real)0,Real a=(Real)1):
28  Vector<4,Real>(r,g,b,a) {}
29 
30  Color(const Vector<3,Real> &other)
31  { this->Vector<4,Real>::operator=(other);
32  m_data[3]=1.0; }
33 
34  Color(const Vector<4,Real> &other)
35  { this->Vector<4,Real>::operator=(other); }
36 
37  template<typename U>
38  Color(const Vector<3,U> &other)
39  { this->Vector<4,Real>::operator=(other);
40  m_data[3]=1.0; }
41 
42  template<typename U>
43  Color(const Vector<4,U> &other)
44  { this->Vector<4,Real>::operator=(other); }
45 
46  Color(const Real* array)
47  { operator=(array); }
48 };
49 
50 inline Color& set(Color &lhs)
51 {
52  lhs[0]=Real(0);
53  lhs[1]=Real(0);
54  lhs[2]=Real(0);
55  lhs[3]=Real(1);
56  return lhs;
57 }
58 
59 template<typename U>
60 inline Color& set(Color &lhs, U r)
61 {
62  lhs[0]=(Real)r;
63  lhs[1]=Real(0);
64  lhs[2]=Real(0);
65  lhs[3]=Real(1);
66  return lhs;
67 }
68 
69 template<typename U, typename V>
70 inline Color& set(Color &lhs, U r, V g)
71 {
72  lhs[0]=(Real)r;
73  lhs[1]=(Real)g;
74  lhs[2]=Real(0);
75  lhs[3]=Real(1);
76  return lhs;
77 }
78 
79 template<typename U, typename V, typename W>
80 inline Color& set(Color &lhs, U r, V g, W b)
81 {
82  lhs[0]=(Real)r;
83  lhs[1]=(Real)g;
84  lhs[2]=(Real)b;
85  lhs[3]=Real(1);
86  return lhs;
87 }
88 
89 } /* namespace */
90 
91 #endif /* __math_Color_h__ */
kernel
Definition: namespace.dox:3
Special vector for color (RGBA)
Definition: Color.h:21
Dense vector - size fixed by template.
Definition: Vector.h:19