Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Color.h

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: Color.h,v 1.4 2002/01/11 14:34:59 tksuoran Exp $
00022 */
00023 
00024 
00025 #ifndef TEDDY__GRAPHICS__COLOR__H
00026 #define TEDDY__GRAPHICS__COLOR__H
00027 
00028 
00029 namespace Teddy    {
00030 namespace Graphics {         
00031 
00032 
00033 //  Quick shortcut, not very smart...
00034 #ifndef SWIG
00035 #define C_BLACK           0.00,0.00,0.00
00036 #define C_WHITE           1.00,1.00,1.00
00037 #define C_RED             1.00,0.00,0.00
00038 #define C_GREEN           0.00,1.00,0.00
00039 #define C_BLUE            0.00,0.00,1.00
00040 #define C_GRAY            0.50,0.50,0.50
00041 #define C_CYAN            0.00,1.00,1.00
00042 #define C_MAGENTA         1.00,0.00,1.00
00043 #define C_YELLOW          1.00,1.00,0.00
00044 #define C_ORANGE          1.00,0.50,0.00
00045 #define C_DARK_RED        0.50,0.00,0.00
00046 #define C_DARK_GREEN      0.00,0.50,0.00
00047 #define C_DARK_BLUE       0.00,0.00,0.50
00048 #define C_DARK_GRAY       0.25,0.25,0.25
00049 #define C_DARK_CYAN       0.00,0.50,0.50
00050 #define C_DARK_MAGENTA    0.50,0.00,0.50
00051 #define C_DARK_YELLOW     0.50,0.50,0.00
00052 #define C_DARK_ORANGE     0.50,0.25,0.00
00053 #define C_LIGHT_RED       1.00,0.50,0.50
00054 #define C_LIGHT_GREEN     0.50,1.00,0.50
00055 #define C_LIGHT_BLUE      0.50,0.50,1.00
00056 #define C_LIGHT_GRAY      0.75,0.75,0.75
00057 #define C_LIGHT_CYAN      0.50,1.00,1.00
00058 #define C_LIGHT_MAGENTA   1.00,0.50,1.00
00059 #define C_LIGHT_YELLOW    1.00,1.00,0.50
00060 #define C_LIGHT_ORANGE    1.00,0.75,0.50
00061 #define C_GRAY_50         0.50,0.50,0.50
00062 #define C_GRAY_25         0.25,0.25,0.25
00063 #define C_GRAY_75         0.75,0.75,0.75
00064 #endif
00065 
00066 
00073 class Color {
00074 public:
00075     static float maxrgb ( float r, float g, float b );
00076     static float minrgb ( float r, float g, float b );
00077     static void  rgb2hsv( float r, float g, float b, float *hout, float *sout, float *vout );
00078     static void  hsv2rgb( float hin, float s, float v, float *rout, float *gout, float *bout );
00079 
00080 public:
00081     float rgba[4];  
00082 
00083     Color();
00084     Color( const float r, const float g, const float b );
00085     Color( const float r, const float g, const float b, const float a );
00086     Color( const float rgba[4] );
00087 
00088     void   debug     ();
00089     void   glApply   () const;
00090     Color  operator+ ( const Color &c ) const;
00091     Color &operator+=( const Color &c );
00092     Color  operator- ( const Color &c ) const;
00093     Color &operator-=( const Color &c );
00094     Color  operator* ( const float &k ) const;
00095     Color &operator*=( const float &k );
00096 
00097     //  Some predefined Colors
00098     static Color BLACK;
00099     static Color WHITE;
00100     static Color RED;
00101     static Color GREEN;
00102     static Color BLUE;
00103     static Color GRAY;
00104     static Color CYAN;
00105     static Color MAGENTA;
00106     static Color YELLOW;
00107     static Color ORANGE;
00108     static Color DARK_RED;
00109     static Color DARK_GREEN;
00110     static Color DARK_BLUE;
00111     static Color DARK_CYAN;
00112     static Color DARK_MAGENTA;
00113     static Color DARK_YELLOW;
00114     static Color DARK_ORANGE;
00115     static Color LIGHT_RED;
00116     static Color LIGHT_GREEN;
00117     static Color LIGHT_BLUE;
00118     static Color LIGHT_CYAN;
00119     static Color LIGHT_MAGENTA;
00120     static Color LIGHT_YELLOW;
00121     static Color LIGHT_ORANGE;
00122     static Color GRAY_50;
00123     static Color GRAY_25;
00124     static Color GRAY_75;
00125 };
00126 
00127 
00128 };  //  namespace Graphics
00129 };  //  namespace Teddy
00130 
00131 
00132 #endif  //  TEDDY__GRAPHICS__COLOR__H
00133