Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Tools/ColorClasses.h

Go to the documentation of this file.

    00001 /**
    00002 * @file ColorClasses.h
    00003 * Declaration of class ColorClasses
    00004 *
    00005 * @author <A href=mailto:timlaue@informatik.uni-bremen.de>Tim Laue</A>
    00006 * @author Martin Lötzsch
    00007 */
    00008
    00009 #ifndef __ColorClasses_h__
    00010 #define __ColorClasses_h__
    00011
    00012 #include "Tools/Debugging/DebugDrawings.h"
    00013
    00014 /** color classes used for objects in the world */
    00015 enum colorClass
    00016 {
    00017   noColor, /*<! all other objects */
    00018     orange, /*<! ball */
    00019     yellow, /*<! yellow goal and flag */
    00020     skyblue, /*<! skyblue goal and flag */
    00021     pink, /*<! pink flag */
    00022     red, /*<! red player */
    00023     blue, /*<! blue player */
    00024     green, /*<! playground and green flag */
    00025     gray, /*<! player */
    00026     white, /*<! boundaries and lines */
    00027     black, /*<! for ball-challenge */
    00028     yellowOrange, /*<! ball or yellow goal */
    00029      numOfColors /*<! number of colors */
    00030 };
    00031
    00032 /**
    00033 * @class ColorClasses
    00034 *
    00035 * Static class for color class functions.
    00036 *
    00037 * @author <A href=mailto:timlaue@informatik.uni-bremen.de>Tim Laue</A>
    00038 * @author Martin Lötzsch
    00039 */
    00040 class ColorClasses
    00041 {
    00042 public:
    00043   /**
    00044    * Returns the RBG-Value for a color class
    00045    * @param color The color class
    00046    * @return The RGB value
    00047    */
    00048   static unsigned long colorClassToRGB(colorClass color)
    00049   {
    00050     int r,g,b;
    00051
    00052     switch(color)
    00053     {
    00054       case orange:  r = 255; g = 128; b = 64;  break;
    00055       case yellow:  r = 255; g = 255; b = 0;   break;
    00056       case skyblue: r = 0;   g = 128; b = 255; break;
    00057       case pink:    r = 255; g = 0;   b = 255; break;
    00058       case red:     r = 255; g = 0;   b = 0;   break;
    00059       case blue:    r = 0;   g = 0;   b = 128; break;
    00060       case gray:    r = 128; g = 128; b = 128; break;
    00061       case green:   r = 0;   g = 255; b = 0;   break;
    00062       case white:   r = 255; g = 255; b = 255; break;
    00063       case black:   r = 0; g = 0; b = 0; break;
    00064       case yellowOrange:   r = 255; g = 192; b = 32; break;
    00065       default: r = 0; g = 96; b = 128; break;
    00066     };
    00067
    00068     return b*0x10000+g*0x100+r;
    00069   }
    00070
    00071   /**
    00072    * Returns the name of a color class
    00073    * @param color The color class
    00074    * @return The name
    00075    */
    00076   static const char* getColorName(colorClass color)
    00077   {
    00078     switch(color)
    00079     {
    00080     case noColor: return "no color";
    00081     case orange: return "orange";
    00082     case yellow: return "yellow";
    00083     case skyblue: return "sky blue";
    00084     case pink: return "pink";
    00085     case red: return "red";
    00086     case blue: return "blue";
    00087     case green: return "green";
    00088     case gray: return "gray";
    00089     case white: return "white";
    00090     case black: return "black";
    00091     case yellowOrange: return "yellowOrange";
    00092     default: return "unknown color!";
    00093     };
    00094   }
    00095
    00096   /**
    00097    * Returns the name of a color class
    00098    * @param color The color class
    00099    * @return The name
    00100    */
    00101   static const char* getShortColorName(colorClass color)
    00102   {
    00103     switch(color)
    00104     {
    00105     case noColor: return "noColor";
    00106     case orange: return "orange";
    00107     case yellow: return "yellow";
    00108     case skyblue: return "skyBlue";
    00109     case pink: return "pink";
    00110     case red: return "red";
    00111     case blue: return "blue";
    00112     case green: return "green";
    00113     case gray: return "gray";
    00114     case white: return "white";
    00115     case black: return "black";
    00116     case yellowOrange: return "yellowOrange";
    00117     default: return "unknown color!";
    00118     };
    00119   }
    00120
    00121   static Drawings::Color colorClassToDrawingsColor(colorClass color)
    00122   {
    00123     switch(color)
    00124     {
    00125     case noColor: return Drawings::black;
    00126     case orange: return Drawings::orange;
    00127     case yellow: return Drawings::yellow;
    00128     case skyblue: return Drawings::skyblue;
    00129     case pink: return Drawings::pink;
    00130     case red: return Drawings::red;
    00131     case blue: return Drawings::blue;
    00132     case green: return Drawings::green;
    00133     case gray: return Drawings::gray;
    00134     case white: return Drawings::white;
    00135     case black: return Drawings::black;
    00136     case yellowOrange: return Drawings::yellowOrange;
    00137     default: return Drawings::white;
    00138     };
    00139   }
    00140 };
    00141
    00142 #endif //__ColorClasses_h_