color.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // This file is part of libgvectors.
00004 // libgvectors is a C++ library intended for visualizing mathematical vectors.
00005 // Copyright (C) 2007  Rafael Ostertag
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program 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
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
00020 // USA.
00021 //
00022 // $Id: color_8h-source.html,v 1.1 2007-09-08 19:02:31 rafi Exp $
00023 //
00024 // File:   color.h
00025 // Author: Rafael Ostertag
00026 //
00027 // Created on August 13, 2007, 7:24 PM
00028 //
00029 
00039 #ifndef _COLOR_H
00040 #define _COLOR_H
00041 
00048 namespace GVectors {
00049    
00056     class Color {
00057     private:
00063         float c_red;
00069         float c_green;
00075         float c_blue;
00076         
00077     public:
00083         inline Color() : c_red(0), c_green(0), c_blue(0) { ; }
00084 
00096         inline Color(float r, float g, float b) : c_red(r), c_green(g), c_blue(b) { ; }
00097 
00105         inline Color(const Color& c) : c_red(c.c_red), c_green(c.c_green), c_blue(c.c_blue) { ; }
00106 
00112         inline ~Color() { ; }
00113 
00123         inline const Color& operator=(const Color& c) {
00124             c_red = c.c_red;
00125             c_green = c.c_green;
00126             c_blue = c.c_blue;
00127             return *this;
00128         }
00129         
00137         inline void red(float r) { c_red = r; }
00138 
00146         inline void green(float g) { c_green = g; }
00147 
00155         inline void blue(float b) { c_blue = b; }
00156 
00164         inline float red() const { return c_red; }
00165 
00173         inline float green() const { return c_green; }
00174 
00182         inline float blue() const { return c_blue; }
00183         
00193         inline Color operator+(const Color& c) {
00194             return Color(c_red+c.c_red, c_green+c.c_green, c_blue+c.c_blue);
00195         }
00196 
00206         inline Color operator-(const Color& c) {
00207             return Color(c_red-c.c_red, c_green-c.c_green, c_blue-c.c_blue);
00208         }
00209     };
00210 }
00211 
00212 #endif  /* _COLOR_H */
00213 

Generated on Sat Sep 8 19:37:29 2007 for libgvectors by  doxygen 1.4.7