Main Page   Class Hierarchy   Compound List   File List   Compound Members  

colColourRGB.cpp

00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 2001-2002 David Pritchard <drpritch@alumni.uwaterloo.ca>
00003 // 
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later
00008 // version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser 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 #include <freecloth/colour/colColourRGB.h>
00020 
00021 ////////////////////////////////////////////////////////////////////////////////
00022 // LOCAL DECLARATIONS
00023 
00024 ////////////////////////////////////////////////////////////////////////////////
00025 // CLASS ColColourRGB
00026 
00027 const ColColourRGB ColColourRGB::BLACK( 0.f, 0.f, 0.f );
00028 const ColColourRGB ColColourRGB::WHITE( 1.f, 1.f, 1.f );
00029 const ColColourRGB ColColourRGB::RED( 1.f, 0.f, 0.f );
00030 const ColColourRGB ColColourRGB::GREEN( 0.f, 1.f, 0.f );
00031 const ColColourRGB ColColourRGB::BLUE( 0.f, 0.f, 1.f );
00032 const ColColourRGB ColColourRGB::CYAN( 0.f, 1.f, 1.f );
00033 const ColColourRGB ColColourRGB::MAGENTA( 1.f, 0.f, 1.f );
00034 const ColColourRGB ColColourRGB::YELLOW( 1.f, 1.f, 0.f );
00035 
00036 //------------------------------------------------------------------------------
00037 
00038 ColColourRGB::ColColourRGB()
00039 {}
00040 
00041 //------------------------------------------------------------------------------
00042 
00043 ColColourRGB::ColColourRGB( Float r, Float g, Float b )
00044     : _r( r ), _g( g ), _b( b )
00045 {}
00046 
00047 //------------------------------------------------------------------------------
00048 
00049 ColColourRGB::ColColourRGB(
00050     const ColColourRGB& colA,
00051     const ColColourRGB& colB,
00052     Float fracA
00053 ) : _r( colA._r * fracA + colB._r * ( 1 - fracA ) ),
00054     _g( colA._g * fracA + colB._g * ( 1 - fracA ) ),
00055     _b( colA._b * fracA + colB._b * ( 1 - fracA ) )
00056 {
00057 }
00058 
00059 //------------------------------------------------------------------------------
00060 
00061 ColColourRGB& ColColourRGB::operator*=( Float val )
00062 {
00063     _r *= val;
00064     _g *= val;
00065     _b *= val;
00066     return *this;
00067 }
00068 
00069 //------------------------------------------------------------------------------
00070 
00071 ColColourRGB ColColourRGB::operator*( Float val ) const
00072 {
00073     ColColourRGB result( *this );
00074     result *= val;
00075     return result;
00076 }
00077 
00078 ////////////////////////////////////////////////////////////////////////////////
00079 // GLOBAL FUNCTIONS
00080 //
00081 
00082 //------------------------------------------------------------------------------
00083 
00084 std::ostream& operator<<( std::ostream& os, const ColColourRGB& c )
00085 {
00086     os << "rgb(" << c._r << "," << c._g << "," << c._b << ")";
00087     return os;
00088 }

Generated on Wed Apr 23 15:58:51 2003 for Freecloth by doxygen1.3-rc3