color.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
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 for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #ifndef __COLOR_H
00025 #define __COLOR_H
00026 
00027 #include <osg/Vec4>
00028 #include <iostream>
00029 
00030 namespace lpzrobots{
00031 
00032 class Color : public osg::Vec4
00033 {
00034 public:
00035   Color() {};
00036   Color(const osg::Vec4& color) 
00037     : osg::Vec4(color)  {};
00038   Color(float r, float g, float b)
00039     : osg::Vec4(r, g, b, 1.0){} 
00040   Color(float r, float g, float b, float a)
00041     : osg::Vec4(r, g, b, a){} 
00042 
00043   static Color rgb255(unsigned char r, unsigned char g, unsigned char b, 
00044                       unsigned char a = 255){
00045     return Color(((float)r)/255.0, ((float)g)/255.0, ((float)b)/255.0, ((float)a)/255.0); 
00046   }
00047 
00048   void print(std::ostream& out) const {
00049     out << '(' << r() << ',' << g() << ',' << b() << ',' << a() << ')';
00050   }
00051 
00052   friend std::ostream& operator<<(std::ostream& out, const Color& col) {
00053     col.print(out);
00054     return out;
00055   }
00056 
00057 /*   float r() const { return x(); } */
00058 /*   float& r() { return x(); } */
00059 /*   float g() const { return y(); } */
00060 /*   float& g() { return y(); } */
00061 /*   float b() const { return z(); } */
00062 /*   float& b() { return z(); } */
00063 /*   float a() const { return w(); } */
00064 /*   float& a() { return w(); } */
00065   float alpha() const { return w(); }
00066   float& alpha() { return w(); }
00067 };
00068   
00069 }
00070 
00071 #endif
Generated on Thu Jun 28 14:45:36 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3