color_utils.cpp
Go to the documentation of this file.
00001 // -*- mode: c++ -*-
00002 /*********************************************************************
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2014, JSK Lab
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/o2r other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of the JSK Lab nor the names of its
00019  *     contributors may be used to endorse or promote products derived
00020  *     from this software without specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
00034  *********************************************************************/
00035 
00036 #include "jsk_topic_tools/color_utils.h"
00037 
00038 namespace jsk_topic_tools
00039 {
00040   std_msgs::ColorRGBA colorCategory20(int i)
00041   {
00042     std_msgs::ColorRGBA c;
00043     c.a = 1.0;
00044     switch (i % 20) {
00045     case 0:
00046     {
00047       c.r = 0.121569;
00048       c.g = 0.466667;
00049       c.b = 0.705882;
00050     }
00051     break;
00052     case 1:
00053     {
00054       c.r = 0.682353;
00055       c.g = 0.780392;
00056       c.b = 0.909804;
00057     }
00058     break;
00059     case 2:
00060     {
00061       c.r = 1.000000;
00062       c.g = 0.498039;
00063       c.b = 0.054902;
00064     }
00065     break;
00066     case 3:
00067     {
00068       c.r = 1.000000;
00069       c.g = 0.733333;
00070       c.b = 0.470588;
00071     }
00072     break;
00073     case 4:
00074     {
00075       c.r = 0.172549;
00076       c.g = 0.627451;
00077       c.b = 0.172549;
00078     }
00079     break;
00080     case 5:
00081     {
00082       c.r = 0.596078;
00083       c.g = 0.874510;
00084       c.b = 0.541176;
00085     }
00086     break;
00087     case 6:
00088     {
00089       c.r = 0.839216;
00090       c.g = 0.152941;
00091       c.b = 0.156863;
00092     }
00093     break;
00094     case 7:
00095     {
00096       c.r = 1.000000;
00097       c.g = 0.596078;
00098       c.b = 0.588235;
00099     }
00100     break;
00101     case 8:
00102     {
00103       c.r = 0.580392;
00104       c.g = 0.403922;
00105       c.b = 0.741176;
00106     }
00107     break;
00108     case 9:
00109     {
00110       c.r = 0.772549;
00111       c.g = 0.690196;
00112       c.b = 0.835294;
00113     }
00114     break;
00115     case 10:
00116     {
00117       c.r = 0.549020;
00118       c.g = 0.337255;
00119       c.b = 0.294118;
00120     }
00121     break;
00122     case 11:
00123     {
00124       c.r = 0.768627;
00125       c.g = 0.611765;
00126       c.b = 0.580392;
00127     }
00128     break;
00129     case 12:
00130     {
00131       c.r = 0.890196;
00132       c.g = 0.466667;
00133       c.b = 0.760784;
00134     }
00135     break;
00136     case 13:
00137     {
00138       c.r = 0.968627;
00139       c.g = 0.713725;
00140       c.b = 0.823529;
00141     }
00142     break;
00143     case 14:
00144     {
00145       c.r = 0.498039;
00146       c.g = 0.498039;
00147       c.b = 0.498039;
00148     }
00149     break;
00150     case 15:
00151     {
00152       c.r = 0.780392;
00153       c.g = 0.780392;
00154       c.b = 0.780392;
00155     }
00156     break;
00157     case 16:
00158     {
00159       c.r = 0.737255;
00160       c.g = 0.741176;
00161       c.b = 0.133333;
00162     }
00163     break;
00164     case 17:
00165     {
00166       c.r = 0.858824;
00167       c.g = 0.858824;
00168       c.b = 0.552941;
00169     }
00170     break;
00171     case 18:
00172     {
00173       c.r = 0.090196;
00174       c.g = 0.745098;
00175       c.b = 0.811765;
00176     }
00177     break;
00178     case 19:
00179     {
00180       c.r = 0.619608;
00181       c.g = 0.854902;
00182       c.b = 0.898039;
00183     }
00184     break;
00185     }
00186     return c;
00187   }
00188 
00189   std_msgs::ColorRGBA heatColor(double v)
00190   {
00191     double ratio = 2 * v;
00192     int b = std::max(0.0, 255 * (1.0 - ratio));
00193     int r = std::max(0.0, 255 * (ratio - 1.0));
00194     int g = 255 - b - r;
00195     std_msgs::ColorRGBA color;
00196     color.a = 1.0;
00197     color.r = r / 255.0;
00198     color.g = g / 255.0;
00199     color.b = b / 255.0;
00200     return color;
00201   }
00202 
00203 }


jsk_topic_tools
Author(s): Kei Okada , Yusuke Furuta
autogenerated on Fri Sep 8 2017 03:38:56