last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 1998 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * 00006 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00007 * 00008 * The CVR-Lib is free software; you can redistribute it and/or 00009 * modify it under the terms of the BSD License. 00010 * 00011 * All rights reserved. 00012 * 00013 * Redistribution and use in source and binary forms, with or without 00014 * modification, are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 00023 * 3. Neither the name of the authors nor the names of its contributors may be 00024 * used to endorse or promote products derived from this software without 00025 * specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 */ 00039 00040 00041 00042 /** 00043 * \file cvrColors.h 00044 * This file contains some more symbolic color definitions, 00045 * like orange, pink, red, green, blue, etc. 00046 * \author Jochen Wickel 00047 * \date 12.11.01 00048 * 00049 * $Id: cvrColors.h,v 1.5 2007/04/16 16:36:30 alvarado Exp $ 00050 */ 00051 00052 #ifndef _CVR_COLORS_H_ 00053 #define _CVR_COLORS_H_ 00054 00055 #include "cvrRGBAPixel.h" 00056 #include "cvrMath.h" 00057 00058 namespace cvr { 00059 00060 /** 00061 * @name Color Constants. 00062 * 00063 * These color constants are defined in the file cvrColors.h. 00064 * 00065 * Note that the color names are all own 00066 * creations, they are not correlated to any official naming 00067 * standards at all. 00068 */ 00069 //@{ 00070 00071 // primary and secondary color constants 00072 00073 /** 00074 * Constant for the color black. 00075 */ 00076 static const rgbaPixel Black(0,0,0); 00077 00078 /** 00079 * Constant for the color read. 00080 */ 00081 static const rgbaPixel Red(255,0,0); 00082 00083 /** 00084 * Constant for the color green. 00085 */ 00086 static const rgbaPixel Green(0,255,0); 00087 00088 /** 00089 * Constant for the color blue. 00090 */ 00091 static const rgbaPixel Blue(0,0,255); 00092 00093 /** 00094 * Constant for the color yellow. 00095 */ 00096 static const rgbaPixel Yellow(255,255,0); 00097 00098 /** 00099 * Constant for the color magenta. 00100 */ 00101 static const rgbaPixel Magenta(255,0,255); 00102 00103 /** 00104 * Constant for the color cyan. 00105 */ 00106 static const rgbaPixel Cyan(0,255,255); 00107 00108 /** 00109 * Constant for the color white. 00110 */ 00111 static const rgbaPixel White(255,255,255); 00112 00113 // darker primary colors 00114 00115 /** 00116 * Constant for dark red 00117 */ 00118 static const rgbaPixel DarkRed(127,0,0); 00119 00120 /** 00121 * Constant for dark green 00122 */ 00123 static const rgbaPixel DarkGreen(0,127,0); 00124 00125 /** 00126 * Constant for dark blue 00127 */ 00128 static const rgbaPixel DarkBlue(0,0,127); 00129 00130 // darker secondary colors 00131 00132 /** 00133 * constant for the color dark yellow 00134 */ 00135 static const rgbaPixel DarkYellow(127,127,0); 00136 00137 /** 00138 * constant for some kind of dark cyan. 00139 */ 00140 static const rgbaPixel DarkCyan(0,127,127); 00141 00142 /** 00143 * constant for some kind of dark magenta. 00144 */ 00145 static const rgbaPixel DarkMagenta(127,0,127); 00146 00147 // brighter primary colors 00148 00149 /** 00150 * constant for a kind of bright green. 00151 */ 00152 static const rgbaPixel BrightGreen(0,255,127); 00153 00154 /** 00155 * constant for a kind of bright green. 00156 */ 00157 static const rgbaPixel BrightBlue(0,127,255); 00158 00159 /** 00160 * constant for a kind of bright red. 00161 */ 00162 static const rgbaPixel BrightRed(255,127,64); 00163 00164 // brighter secondary colors 00165 00166 /** 00167 * constant for some kind of bright magenta. 00168 */ 00169 static const rgbaPixel BrightMagenta(255,127,255); 00170 00171 /** 00172 * constant for some kind of bright yellow. 00173 */ 00174 static const rgbaPixel BrightYellow(255,255,127); 00175 00176 /** 00177 * constant for some kind of bright cyan. 00178 */ 00179 static const rgbaPixel BrightCyan(127,255,255); 00180 00181 00182 // other colors 00183 00184 /** 00185 * constant for the color orange. 00186 */ 00187 static const rgbaPixel DarkOrange(192,64,0); 00188 00189 /** 00190 * constant for the color fusia. 00191 */ 00192 static const rgbaPixel Fusia(255,0,127); 00193 00194 /** 00195 * constant for the color pink. 00196 */ 00197 static const rgbaPixel Pink(255,127,127); 00198 00199 /** 00200 * constant for another kind of bright green. 00201 */ 00202 static const rgbaPixel LawnGreen(127,255,0); 00203 00204 /** 00205 * constant for some kind of lemon color 00206 */ 00207 static const rgbaPixel Lemon(127,255,127); 00208 00209 /** 00210 * constant for a light blue. 00211 */ 00212 static const rgbaPixel LightBlue(0,127,255); 00213 00214 /** 00215 * constant for a light blue. 00216 */ 00217 static const rgbaPixel DarkViolet(127,0,255); 00218 00219 /** 00220 * constant for the color violet. 00221 */ 00222 static const rgbaPixel Violet(127,127,255); 00223 00224 /** 00225 * Function for scaling a color's intensity. 00226 * @param src rgbaPixel of the original color 00227 * @param f factor by which to multiply the R, G and B values. Warning: 00228 * Saturation effects might lead to strange results. 00229 * @return rgbaPixel where R, G and B have the given value <code>t</code>. 00230 */ 00231 inline rgbaPixel scale(const rgbaPixel& src, double f) { 00232 return rgbaPixel(static_cast<ubyte>(within(src.getRed() *f,0.0,255.0)), 00233 static_cast<ubyte>(within(src.getGreen()*f,0.0,255.0)), 00234 static_cast<ubyte>(within(src.getBlue() *f,0.0,255.0))); 00235 } 00236 00237 /** 00238 * Function for darkening a color. 00239 * @param src rgbaPixel of the original color 00240 * @param f factor which tells how much darker the new color should be. 00241 * Example: 0.2 means: Make the color 20% darker. 0 means: 00242 * leave the original, 1.0 means: make it black 00243 * @return rgbaPixel where R, G and B have the given value <code>t</code>. 00244 */ 00245 inline rgbaPixel darker(const rgbaPixel& src, double f=0.5) { 00246 return scale(src,(1.0-f)); 00247 } 00248 00249 /** 00250 * Function for brightening a color. 00251 * @param src rgbaPixel of the original color 00252 * @param f factor which tells how much darker the new color should be. 00253 * Example: 0.2 means: Make the color 20% brighter. 0 means: 00254 * leave the original, 1.0 means: make it twice as bright. Warning: 00255 * Saturation effects might lead to strange results. 00256 * @return rgbaPixel where R, G and B have the given value <code>t</code>. 00257 */ 00258 inline rgbaPixel brighter(const rgbaPixel& src, double f=0.5) { 00259 return scale(src,(1.0+f)); 00260 } 00261 00262 00263 /** 00264 * function for returning a grey value. 00265 * @param t grey value must be between 0 and 255 00266 * @return rgbaPixel where R, G and B have the given value <code>t</code>. 00267 */ 00268 inline rgbaPixel grey(int t) { 00269 return rgbaPixel(t,t,t); 00270 } 00271 00272 /** 00273 * function for returning a gray value. 00274 * @param t grey value must be between 0 and 255 00275 * @return rgbaPixel where R, G and B have the given value <code>t</code>. 00276 */ 00277 inline rgbaPixel gray(int t) { 00278 return rgbaPixel(t,t,t); 00279 } 00280 00281 /** 00282 * function for returning a grey value. 00283 * @param t grey value must be between 0 and 1 00284 * @return rgbaPixel where R, G and B have the given value <code>t*255</code>. 00285 */ 00286 inline rgbaPixel grey(double t) { 00287 return rgbaPixel(int(t*255),int(t*255),int(t*255.0)); 00288 } 00289 00290 /** 00291 * function for returning a gray value. 00292 * @param t grey value must be between 0 and 1 00293 * @return rgbaPixel where R, G and B have the given value <code>t*255</code>. 00294 */ 00295 inline rgbaPixel gray(double t) { 00296 return rgbaPixel(int(t*255),int(t*255),int(t*255.0)); 00297 } 00298 00299 /** 00300 * Definition for a 100% bright grey, i.e. White 00301 */ 00302 static const rgbaPixel Grey100(255,255,255); 00303 00304 /** 00305 * Definition for a 75% bright grey, i.e. bright grey 00306 */ 00307 static const rgbaPixel Grey75(191,191,191); 00308 00309 /** 00310 * Definition for a 50% bright grey, i.e. medium grey 00311 */ 00312 static const rgbaPixel Grey50(127,127,127); 00313 00314 /** 00315 * Definition for a 25% bright grey, i.e. dark grey 00316 */ 00317 static const rgbaPixel Grey25(63,63,63); 00318 00319 /** 00320 * Definition for a 0% bright grey, i.e. Black 00321 */ 00322 static const rgbaPixel Grey0(0,0,0); 00323 00324 } 00325 00326 #endif 00327