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

sdlmm_color.h

Go to the documentation of this file.
00001 /*
00002  * SDLmm - a C++ wrapper for SDL and related libraries
00003  * Copyright © 2001 David Hedbor <david@hedbor.org>
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License as
00007  * published by the Free Software Foundation; either version 2 of the
00008  * License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *
00019  */
00020 
00021 #ifndef SDLMM_COLOR_H
00022 #define SDLMM_COLOR_H
00023 
00024 namespace SDLmm {
00025   typedef Uint32 Color;
00026 
00032   class ColorRGB {
00033   public:
00036     ColorRGB() : r(0), g(0), b(0) {
00037     }
00038 
00041 
00042     ColorRGB(const ColorRGB& color) : r(color.r), g(color.g), b(color.b) {
00043     }
00044 
00046 
00051     ColorRGB(Uint8 nr, Uint8 ng, Uint8 nb) : r(nr), g(ng), b(nb) {
00052     }
00053 
00055     ColorRGB& operator=(const ColorRGB& color) {
00056       if(this != &color)
00057       {
00058         r = color.r;
00059         g = color.g;
00060         b = color.b;
00061       }
00062       return *this;
00063     }
00064 
00066 
00069     bool operator==(const ColorRGB& color) const {
00070       return ((r == color.r) && (g == color.g) && (b == color.b));
00071     }
00072     
00073     Uint8 r;
00074     Uint8 g;
00075     Uint8 b;
00076   };
00077 
00083   class ColorRGBA : public ColorRGB {
00084   public:
00087     ColorRGBA() : ColorRGB(), a(0) {
00088     }
00089 
00092 
00093     ColorRGBA(const ColorRGBA& color) : ColorRGB(color), a(color.a) {
00094     }
00095 
00097 
00103     ColorRGBA(Uint8 nr, Uint8 ng, Uint8 nb, Uint8 na) : ColorRGB(nr, ng, nb), a(na) {
00104     }
00105 
00107     ColorRGBA& operator=(const ColorRGBA& color) {
00108       if(this != &color)
00109       {
00110         ColorRGB::operator=(color);
00111         a = color.a;
00112       }
00113       return *this;
00114     }
00115 
00117 
00120     bool operator==(const ColorRGBA& color) const {
00121       return (ColorRGB::operator==(color) && (a == color.a));
00122     }
00123     
00124     Uint8 a;
00125   };
00126 }
00127 
00128 #endif // SDLMM_COLOR_H
00129 

Documentation automatically generated by doxygen written by Dimitri van Heesch. Project hosted at
Hosted by SourceForge