Main Page
Namespaces
Classes
Files
File List
File Members
src
color_utils.cpp
Go to the documentation of this file.
1
// -*- mode: c++ -*-
2
/*********************************************************************
3
* Software License Agreement (BSD License)
4
*
5
* Copyright (c) 2014, JSK Lab
6
* All rights reserved.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
10
* are met:
11
*
12
* * Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
14
* * Redistributions in binary form must reproduce the above
15
* copyright notice, this list of conditions and the following
16
* disclaimer in the documentation and/o2r other materials provided
17
* with the distribution.
18
* * Neither the name of the JSK Lab nor the names of its
19
* contributors may be used to endorse or promote products derived
20
* from this software without specific prior written permission.
21
*
22
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
* POSSIBILITY OF SUCH DAMAGE.
34
*********************************************************************/
35
36
#include "
jsk_topic_tools/color_utils.h
"
37
38
namespace
jsk_topic_tools
39
{
40
std_msgs::ColorRGBA
colorCategory20
(
int
i)
41
{
42
std_msgs::ColorRGBA c;
43
c.a = 1.0;
44
switch
(i % 20) {
45
case
0:
46
{
47
c.r = 0.121569;
48
c.g = 0.466667;
49
c.b = 0.705882;
50
}
51
break
;
52
case
1:
53
{
54
c.r = 0.682353;
55
c.g = 0.780392;
56
c.b = 0.909804;
57
}
58
break
;
59
case
2:
60
{
61
c.r = 1.000000;
62
c.g = 0.498039;
63
c.b = 0.054902;
64
}
65
break
;
66
case
3:
67
{
68
c.r = 1.000000;
69
c.g = 0.733333;
70
c.b = 0.470588;
71
}
72
break
;
73
case
4:
74
{
75
c.r = 0.172549;
76
c.g = 0.627451;
77
c.b = 0.172549;
78
}
79
break
;
80
case
5:
81
{
82
c.r = 0.596078;
83
c.g = 0.874510;
84
c.b = 0.541176;
85
}
86
break
;
87
case
6:
88
{
89
c.r = 0.839216;
90
c.g = 0.152941;
91
c.b = 0.156863;
92
}
93
break
;
94
case
7:
95
{
96
c.r = 1.000000;
97
c.g = 0.596078;
98
c.b = 0.588235;
99
}
100
break
;
101
case
8:
102
{
103
c.r = 0.580392;
104
c.g = 0.403922;
105
c.b = 0.741176;
106
}
107
break
;
108
case
9:
109
{
110
c.r = 0.772549;
111
c.g = 0.690196;
112
c.b = 0.835294;
113
}
114
break
;
115
case
10:
116
{
117
c.r = 0.549020;
118
c.g = 0.337255;
119
c.b = 0.294118;
120
}
121
break
;
122
case
11:
123
{
124
c.r = 0.768627;
125
c.g = 0.611765;
126
c.b = 0.580392;
127
}
128
break
;
129
case
12:
130
{
131
c.r = 0.890196;
132
c.g = 0.466667;
133
c.b = 0.760784;
134
}
135
break
;
136
case
13:
137
{
138
c.r = 0.968627;
139
c.g = 0.713725;
140
c.b = 0.823529;
141
}
142
break
;
143
case
14:
144
{
145
c.r = 0.498039;
146
c.g = 0.498039;
147
c.b = 0.498039;
148
}
149
break
;
150
case
15:
151
{
152
c.r = 0.780392;
153
c.g = 0.780392;
154
c.b = 0.780392;
155
}
156
break
;
157
case
16:
158
{
159
c.r = 0.737255;
160
c.g = 0.741176;
161
c.b = 0.133333;
162
}
163
break
;
164
case
17:
165
{
166
c.r = 0.858824;
167
c.g = 0.858824;
168
c.b = 0.552941;
169
}
170
break
;
171
case
18:
172
{
173
c.r = 0.090196;
174
c.g = 0.745098;
175
c.b = 0.811765;
176
}
177
break
;
178
case
19:
179
{
180
c.r = 0.619608;
181
c.g = 0.854902;
182
c.b = 0.898039;
183
}
184
break
;
185
}
186
return
c;
187
}
188
189
std_msgs::ColorRGBA
heatColor
(
double
v)
190
{
191
double
ratio = 2 * v;
192
int
b = std::max(0.0, 255 * (1.0 - ratio));
193
int
r
= std::max(0.0, 255 * (ratio - 1.0));
194
int
g = 255 - b -
r
;
195
std_msgs::ColorRGBA color;
196
color.a = 1.0;
197
color.r = r / 255.0;
198
color.g = g / 255.0;
199
color.b = b / 255.0;
200
return
color;
201
}
202
203
}
jsk_topic_tools::heatColor
std_msgs::ColorRGBA heatColor(double v)
returns heat-map color (http://en.wikipedia.org/wiki/Heat_map)
Definition:
color_utils.cpp:189
color_utils.h
Provide color utility functions.
pose_stamped_publisher.r
r
Definition:
pose_stamped_publisher.py:42
jsk_topic_tools
Definition:
block_nodelet.h:42
jsk_topic_tools::colorCategory20
std_msgs::ColorRGBA colorCategory20(int i)
choose a color out of 20 good selected colors
Definition:
color_utils.cpp:40
jsk_topic_tools
Author(s): Kei Okada
, Yusuke Furuta
autogenerated on Tue Feb 6 2018 03:45:19