OpenWalnut  1.5.0dev
WColorWrapper.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WCOLORWRAPPER_H_
26 #define WCOLORWRAPPER_H_
27 
28 #include "../../common/WColor.h"
29 
30 /**
31  * Wraps the WColor class for scripts.
32  */
34 {
35 public:
36  /**
37  * Contructs a new wrapper.
38  *
39  * \param r The red component in [0,1].
40  * \param g The green component in [0,1].
41  * \param b The blue component in [0,1].
42  * \param a The alpha component in [0,1].
43  */
44  WColorWrapper( float r, float g, float b, float a )
45  : m_color( r, g, b, a )
46  {
47  }
48 
49  /**
50  * Destructor.
51  */
53  {
54  }
55 
56  /**
57  * Get the red component.
58  *
59  * \return The red component.
60  */
61  float getR() const
62  {
63  return m_color[ 0 ];
64  }
65 
66  /**
67  * Get the green component.
68  *
69  * \return The green component.
70  */
71  float getG() const
72  {
73  return m_color[ 1 ];
74  }
75 
76  /**
77  * Get the blue component.
78  *
79  * \return The blue component.
80  */
81  float getB() const
82  {
83  return m_color[ 2 ];
84  }
85 
86  /**
87  * Get the alpha component.
88  *
89  * \return The alpha component.
90  */
91  float getA() const
92  {
93  return m_color[ 3 ];
94  }
95 
96  /**
97  * Set the red component.
98  *
99  * \param r The red component.
100  */
101  void setR( float r )
102  {
103  m_color[ 0 ] = r;
104  }
105 
106  /**
107  * Set the green component.
108  *
109  * \param g The green component.
110  */
111  void setG( float g )
112  {
113  m_color[ 1 ] = g;
114  }
115 
116  /**
117  * Set the blue component.
118  *
119  * \param b The blue component.
120  */
121  void setB( float b )
122  {
123  m_color[ 2 ] = b;
124  }
125 
126  /**
127  * Set the alpha component.
128  *
129  * \param a The alpha component.
130  */
131  void setA( float a )
132  {
133  m_color[ 3 ] = a;
134  }
135 
136  /**
137  * Get the wrapped color.
138  *
139  * \return The color.
140  */
141  WColor const& get() const
142  {
143  return m_color;
144  }
145 
146 private:
147  //! The color.
148  WColor m_color;
149 };
150 
151 #endif // WCOLORWRAPPER_H_
152 
Wraps the WColor class for scripts.
Definition: WColorWrapper.h:34
WColorWrapper(float r, float g, float b, float a)
Contructs a new wrapper.
Definition: WColorWrapper.h:44
void setG(float g)
Set the green component.
~WColorWrapper()
Destructor.
Definition: WColorWrapper.h:52
float getB() const
Get the blue component.
Definition: WColorWrapper.h:81
WColor const & get() const
Get the wrapped color.
float getG() const
Get the green component.
Definition: WColorWrapper.h:71
float getR() const
Get the red component.
Definition: WColorWrapper.h:61
void setA(float a)
Set the alpha component.
WColor m_color
The color.
void setR(float r)
Set the red component.
float getA() const
Get the alpha component.
Definition: WColorWrapper.h:91
void setB(float b)
Set the blue component.