Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CEGUIColourRect.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIColourRect.cpp
00003         created:        8/3/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Implements ColourRect class
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #include "CEGUIColourRect.h"
00027 
00028 
00029 // Start of CEGUI namespace section
00030 namespace CEGUI
00031 {
00032 /*************************************************************************
00033         Constructor
00034 *************************************************************************/
00035 ColourRect::ColourRect(const colour& top_left, const colour& top_right, const colour& bottom_left, const colour& bottom_right) :
00036         d_top_left(top_left),
00037         d_top_right(top_right),
00038         d_bottom_left(bottom_left),
00039         d_bottom_right(bottom_right)
00040 {
00041 }
00042 
00043 
00044 /*************************************************************************
00045         Constructor for ColourRect objects (via single colour).
00046 *************************************************************************/
00047 ColourRect::ColourRect(const colour& col) :
00048         d_top_left(col),
00049         d_top_right(col),
00050         d_bottom_left(col),
00051         d_bottom_right(col)
00052 {
00053 }
00054 
00055 
00056 /*************************************************************************
00057         Default constructor
00058 *************************************************************************/
00059 ColourRect::ColourRect(void) :
00060         d_top_left(0, 0, 0),
00061         d_top_right(0, 0, 0),
00062         d_bottom_left(0, 0, 0),
00063         d_bottom_right(0, 0, 0)
00064 {
00065 }
00066 
00067 
00068 /*************************************************************************
00069         Destructor
00070 *************************************************************************/
00071 ColourRect::~ColourRect(void)
00072 {
00073 }
00074 
00075 
00076 /*************************************************************************
00077         Set the alpha value to use for all four corners of the ColourRect.      
00078 *************************************************************************/
00079 void ColourRect::setAlpha(float alpha)
00080 {
00081         d_top_left.setAlpha(alpha);
00082         d_top_right.setAlpha(alpha);
00083         d_bottom_left.setAlpha(alpha);
00084         d_bottom_right.setAlpha(alpha);
00085 }
00086 
00087 
00088 /*************************************************************************
00089         Set the alpha value to use for the top edge of the ColourRect.  
00090 *************************************************************************/
00091 void ColourRect::setTopAlpha(float alpha)
00092 {
00093         d_top_left.setAlpha(alpha);
00094         d_top_right.setAlpha(alpha);
00095 }
00096 
00097 
00098 /*************************************************************************
00099         Set the alpha value to use for the bottom edge of the ColourRect.       
00100 *************************************************************************/
00101 void ColourRect::setBottomAlpha(float alpha)
00102 {
00103         d_bottom_left.setAlpha(alpha);
00104         d_bottom_right.setAlpha(alpha);
00105 }
00106 
00107 
00108 /*************************************************************************
00109         Set the alpha value to use for the left edge of the ColourRect. 
00110 *************************************************************************/
00111 void ColourRect::setLeftAlpha(float alpha)
00112 {
00113         d_top_left.setAlpha(alpha);
00114         d_bottom_left.setAlpha(alpha);
00115 }
00116 
00117 
00118 /*************************************************************************
00119         Set the alpha value to use for the right edge of the ColourRect.        
00120 *************************************************************************/
00121 void ColourRect::setRightAlpha(float alpha)
00122 {
00123         d_top_right.setAlpha(alpha);
00124         d_bottom_right.setAlpha(alpha);
00125 }
00126 
00127 /*************************************************************************
00128         Get the colour at a specified point
00129 *************************************************************************/
00130 colour ColourRect::getColourAtPoint( float x, float y ) const
00131 {
00132     colour h1((d_top_right - d_top_left) * x + d_top_left);
00133         colour h2((d_bottom_right - d_bottom_left) * x + d_bottom_left);
00134         return colour((h2 - h1) * y + h1);
00135 }
00136 
00137 /*************************************************************************
00138         Get a ColourRectangle from the specified Region
00139 *************************************************************************/
00140 ColourRect ColourRect::getSubRectangle( float left, float right, float top, float bottom ) const
00141 {
00142         return ColourRect(
00143                 getColourAtPoint(left, top),
00144                 getColourAtPoint(right, top),
00145                 getColourAtPoint(left, bottom),
00146                 getColourAtPoint(right, bottom)
00147         );
00148 }
00149 
00150 
00151 /*************************************************************************
00152         Set the colour of all four corners simultaneously.      
00153 *************************************************************************/
00154 void ColourRect::setColours(const colour& col)
00155 {
00156         d_top_left = d_top_right = d_bottom_left = d_bottom_right = col;
00157 }
00158 
00159 
00160 } // End of  CEGUI namespace section

Generated on Wed Feb 16 12:41:05 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1