Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
color.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __COLOR_H
25 #define __COLOR_H
26 
27 #include <osg/Vec4>
28 #include <iostream>
29 
30 namespace lpzrobots{
31 
32 class Color : public osg::Vec4
33 {
34 public:
35  Color() {};
36  Color(const osg::Vec4& color)
37  : osg::Vec4(color) {};
38  Color(float r, float g, float b)
39  : osg::Vec4(r, g, b, 1.0){}
40  Color(float r, float g, float b, float a)
41  : osg::Vec4(r, g, b, a){}
42 
43  static Color rgb255(unsigned char r, unsigned char g, unsigned char b,
44  unsigned char a = 255){
45  return Color(((float)r)/255.0, ((float)g)/255.0, ((float)b)/255.0, ((float)a)/255.0);
46  }
47 
48  void print(std::ostream& out) const {
49  out << '(' << r() << ',' << g() << ',' << b() << ',' << a() << ')';
50  }
51 
52  friend std::ostream& operator<<(std::ostream& out, const Color& col) {
53  col.print(out);
54  return out;
55  }
56 
57 /* float r() const { return x(); } */
58 /* float& r() { return x(); } */
59 /* float g() const { return y(); } */
60 /* float& g() { return y(); } */
61 /* float b() const { return z(); } */
62 /* float& b() { return z(); } */
63 /* float a() const { return w(); } */
64 /* float& a() { return w(); } */
65  float alpha() const { return w(); }
66  float& alpha() { return w(); }
67 };
68 
69 }
70 
71 #endif
float alpha() const
Definition: color.h:65
static Color rgb255(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
Definition: color.h:43
Color(const osg::Vec4 &color)
Definition: color.h:36
float & alpha()
Definition: color.h:66
Color(float r, float g, float b)
Definition: color.h:38
Color(float r, float g, float b, float a)
Definition: color.h:40
Definition: color.h:32
double g(double z)
neuron transfer function
Definition: regularisation.h:35
void print(std::ostream &out) const
Definition: color.h:48
friend std::ostream & operator<<(std::ostream &out, const Color &col)
Definition: color.h:52
Vec4f Vec4
Definition: osgforwarddecl.h:44
Color()
Definition: color.h:35