Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

IGColor.cpp

Go to the documentation of this file.
00001 /* $Id: IGColor.cpp,v 1.1 2001/05/27 15:25:28 formella Exp $ */
00002 
00003 /*
00004  *  Copyright (C) 2001, Dr. Arno Formella
00005  *                      Universidade de Vigo
00006  *                      Departamento de Informatica
00007  *
00008  *  This program is free software; you can redistribute it and/or modify
00009  *  it under the terms of the GNU General Public License as published by
00010  *  the Free Software Foundation; either version 2 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  This program is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *  GNU General Public License
00017  *          http://www.gnu.ai.mit.edu/copyleft/gpl.html
00018  *  for more details.
00019  */
00020 
00021 #include "IGColor.h"
00022 
00023 double IGColor::Clamp(
00024   double v
00025 ) const {
00026   return(v>1.0?1.0:v<0.0?0.0:v);
00027 }
00028 
00029 IGColor::IGColor(
00030   double gray=0.0
00031 ) {
00032   red=green=blue=Clamp(gray);
00033 }
00034 
00035 IGColor::IGColor(
00036   double r,
00037   double g,
00038   double b
00039 ) :
00040   red(Clamp(r)),
00041   green(Clamp(g)),
00042   blue(Clamp(b))
00043 {
00044 }
00045 
00046 IGColor::IGColor(
00047   const IGColor& C
00048 ) :
00049   red(C.red),
00050   green(C.green),
00051   blue(C.blue)
00052 {
00053 }
00054 
00055 IGColor::~IGColor() {}
00056 
00057 void IGColor::SetColor(
00058 ) const {
00059   glColor3d(red,green,blue);
00060 }
00061 
00062 IGColor& IGColor::operator=(
00063   const IGColor& C
00064 ) {
00065   if(this!=&C) {
00066     red  =C.red;
00067     green=C.green;
00068     blue =C.blue;
00069   }
00070   return(*this);
00071 }
00072 
00073 istream& operator>>(
00074   istream& in,
00075   IGColor& C
00076 ) {
00077   in >> C.red >> C.green >> C.blue;
00078   C.red  =C.Clamp(C.red);
00079   C.green=C.Clamp(C.green);
00080   C.blue =C.Clamp(C.blue);
00081   return(in);
00082 }
00083 
00084 ostream& operator<<(
00085   ostream& out,
00086   const IGColor& C
00087 ) {
00088   out << "Color: (" << C.red << "," << C.green << "," << C.blue << ")" << endl;
00089   return(out);
00090 }
00091 

Generated at Wed May 30 11:16:28 2001 for Computer Graphics Course by doxygen1.1.5 written by Dimitri van Heesch, © 1997-2000