Crazy Eddie's GUI System  0.8.7
ColourRect.h
1 /***********************************************************************
2  created: 8/3/2004
3  author: Paul D Turner
4 
5  purpose: Defines class representing colours for four corners of a
6  rectangle
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIColourRect_h_
31 #define _CEGUIColourRect_h_
32 
33 #include "CEGUI/Base.h"
34 #include "CEGUI/Colour.h"
35 
36 // Start of CEGUI namespace section
37 namespace CEGUI
38 {
43 class CEGUIEXPORT ColourRect :
44  public AllocatedObject<ColourRect>
45 {
46 public:
51  ColourRect(void);
52 
53 
58  ColourRect(const Colour& col);
59 
60 
65  ColourRect(const Colour& top_left, const Colour& top_right, const Colour& bottom_left, const Colour& bottom_right);
66 
67 
78  void setAlpha(float alpha);
79 
80 
91  void setTopAlpha(float alpha);
92 
93 
104  void setBottomAlpha(float alpha);
105 
106 
117  void setLeftAlpha(float alpha);
118 
119 
130  void setRightAlpha(float alpha);
131 
132 
140  bool isMonochromatic() const;
141 
142 
159  ColourRect getSubRectangle( float left, float right, float top, float bottom ) const;
160 
173  Colour getColourAtPoint( float x, float y ) const;
174 
175 
183  void setColours(const Colour& col);
184 
185 
193  void modulateAlpha(float alpha);
194 
200 
201  inline ColourRect operator*(const float val) const
202  {
203  return ColourRect(
204  d_top_left * val,
205  d_top_right * val,
206  d_bottom_left * val,
207  d_bottom_right * val
208  );
209  }
210 
211  inline ColourRect operator+(const ColourRect& val) const
212  {
213  return ColourRect(
214  d_top_left + val.d_top_left,
215  d_top_right + val.d_top_right,
216  d_bottom_left + val.d_bottom_left,
217  d_bottom_right + val.d_bottom_right
218  );
219  }
220 
221 
222  Colour d_top_left, d_top_right, d_bottom_left, d_bottom_right;
223 };
224 
225 } // End of CEGUI namespace section
226 
227 
228 #endif // end of guard _CEGUIColourRect_h_
Definition: MemoryAllocatedObject.h:110
Class that holds details of colours for the four corners of a rectangle.
Definition: ColourRect.h:45
ColourRect(void)
Default constructor.
bool isMonochromatic() const
Determinate the ColourRect is monochromatic or variegated.
void setColours(const Colour &col)
Set the colour of all four corners simultaneously.
void setBottomAlpha(float alpha)
Set the alpha value to use for the bottom edge of the ColourRect.
void setAlpha(float alpha)
Set the alpha value to use for all four corners of the ColourRect.
void setLeftAlpha(float alpha)
Set the alpha value to use for the left edge of the ColourRect.
void setTopAlpha(float alpha)
Set the alpha value to use for the top edge of the ColourRect.
ColourRect(const Colour &col)
Constructor for ColourRect objects (via single colour). Also handles default construction.
ColourRect(const Colour &top_left, const Colour &top_right, const Colour &bottom_left, const Colour &bottom_right)
Constructor for ColourRect objects.
Colour getColourAtPoint(float x, float y) const
Get the colour at a point in the rectangle.
ColourRect getSubRectangle(float left, float right, float top, float bottom) const
Gets a portion of this ColourRect as a subset ColourRect.
void setRightAlpha(float alpha)
Set the alpha value to use for the right edge of the ColourRect.
Colour d_bottom_right
ColourRect component colours.
Definition: ColourRect.h:222
ColourRect & operator*=(const ColourRect &other)
Modulate all components of this colour rect with corresponding components from another colour rect.
void modulateAlpha(float alpha)
Module the alpha components of each corner's colour by a constant.
Class representing colour values within the system.
Definition: Colour.h:46
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
String CEGUIEXPORT operator+(const String &str1, const String &str2)
Return String object that is the concatenation of the given inputs.