Class
List
Heirarchy
Modules
Common
Events
Math
Messages
Physics
Rendering
Sensors
Transport
Links
Gazebo Website
Wiki
Tutorials
Download
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
gazebo
common
Color.hh
Go to the documentation of this file.
1
/*
2
* Copyright 2011 Nate Koenig
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
/* Desc: Color class
18
* Author: Nate Koenig
19
* Date: 08 May 2009
20
*/
21
22
#ifndef GAZEBO_COLOR_HH
23
#define GAZEBO_COLOR_HH
24
25
#include <iostream>
26
#include "
gazebo/common/CommonTypes.hh
"
27
#include "
gazebo/math/Vector3.hh
"
28
29
namespace
gazebo
30
{
31
namespace
common
32
{
35
37
class
Color
38
{
40
public
:
static
const
Color
White
;
42
public
:
static
const
Color
Black
;
44
public
:
static
const
Color
Red
;
46
public
:
static
const
Color
Green
;
48
public
:
static
const
Color
Blue
;
50
public
:
static
const
Color
Yellow
;
52
public
:
static
const
Color
Purple
;
53
54
public
:
typedef
unsigned
int
RGBA
;
55
public
:
typedef
unsigned
int
BGRA
;
56
public
:
typedef
unsigned
int
ARGB
;
57
public
:
typedef
unsigned
int
ABGR
;
58
60
public
:
Color
();
61
67
public
:
Color
(
float
_r,
float
_g,
float
_b,
float
_a = 1.0);
68
71
public
:
Color
(
const
Color
&_clr);
72
74
public
:
virtual
~Color
();
75
77
public
:
void
Reset
();
78
84
public
:
void
Set
(
float
_r = 1,
float
_g = 1 ,
float
_b = 1,
float
_a = 1);
85
88
public
:
math::Vector3
GetAsHSV
()
const
;
89
94
public
:
void
SetFromHSV
(
float
_h,
float
_s,
float
_v);
95
98
public
:
math::Vector3
GetAsYUV
()
const
;
99
104
public
:
void
SetFromYUV
(
float
_y,
float
_u,
float
_v);
105
109
public
:
Color
&
operator =
(
const
Color
&_pt);
110
114
public
:
float
operator[]
(
unsigned
int
_index);
115
118
public
:
RGBA
GetAsRGBA
()
const
;
119
122
public
:
BGRA
GetAsBGRA
()
const
;
123
126
public
:
ARGB
GetAsARGB
()
const
;
127
130
public
:
ABGR
GetAsABGR
()
const
;
131
132
135
public
:
void
SetFromRGBA
(
const
RGBA
_v);
136
139
public
:
void
SetFromBGRA
(
const
BGRA
_v);
140
143
public
:
void
SetFromARGB
(
const
ARGB
_v);
144
147
public
:
void
SetFromABGR
(
const
ABGR
_v);
148
152
public
:
Color
operator+
(
const
Color
&_pt)
const
;
153
157
public
:
Color
operator+
(
const
float
&_v)
const
;
158
162
public
:
const
Color
&
operator+=
(
const
Color
&_pt);
163
167
public
:
Color
operator-
(
const
Color
&_pt)
const
;
168
172
public
:
Color
operator-
(
const
float
&_v)
const
;
173
177
public
:
const
Color
&
operator-=
(
const
Color
&_pt);
178
182
public
:
const
Color
operator/
(
const
Color
&_pt)
const
;
183
187
public
:
const
Color
operator/
(
const
float
&_v)
const
;
188
192
public
:
const
Color
&
operator/=
(
const
Color
&_pt);
193
197
public
:
const
Color
operator*
(
const
Color
&_pt)
const
;
198
202
public
:
const
Color
operator*
(
const
float
&_v)
const
;
203
207
public
:
const
Color
&
operator*=
(
const
Color
&_pt);
208
212
public
:
bool
operator ==
(
const
Color
&_pt)
const
;
213
217
public
:
bool
operator!=
(
const
Color
&_pt)
const
;
218
220
private
:
void
Clamp();
221
226
public
:
friend
std::ostream &
operator<<
(std::ostream &_out,
227
const
Color
&_pt)
228
{
229
_out << _pt.
r
<<
" "
<< _pt.
g
<<
" "
<< _pt.
b
<<
" "
<< _pt.
a
;
230
return
_out;
231
}
232
236
public
:
friend
std::istream &
operator>>
(std::istream &_in,
Color
&_pt)
237
{
238
// Skip white spaces
239
_in.setf(std::ios_base::skipws);
240
_in >> _pt.
r
>> _pt.
g
>> _pt.
b
>> _pt.
a
;
241
return
_in;
242
}
243
244
// The values
245
public
:
float
r
,
g
,
b
,
a
;
246
};
248
}
249
}
250
#endif