SUMO - Simulation of Urban MObility
RGBColor.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A RGB-color definition
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef RGBColor_h
23 #define RGBColor_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <iostream>
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
47 class RGBColor {
48 public:
51  RGBColor();
52 
58  RGBColor(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255);
59 
61  RGBColor(const RGBColor& col);
62 
64  ~RGBColor();
65 
69  unsigned char red() const {
70  return myRed;
71  }
72 
76  unsigned char green() const {
77  return myGreen;
78  }
79 
83  unsigned char blue() const {
84  return myBlue;
85  }
86 
90  unsigned char alpha() const {
91  return myAlpha;
92  }
93 
100  void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
101 
107  RGBColor changedBrightness(int change, int toChange = 3) const;
108 
110  RGBColor invertedColor() const;
111 
123  static RGBColor parseColor(std::string coldef);
124 
140  static RGBColor parseColorReporting(const std::string& coldef, const std::string& objecttype,
141  const char* objectid, bool report, bool& ok);
142 
153  static RGBColor interpolate(const RGBColor& minColor, const RGBColor& maxColor, double weight);
154 
162  static RGBColor fromHSV(double h, double s, double v);
163 
169  friend std::ostream& operator<<(std::ostream& os, const RGBColor& col);
170 
171  // @brief Equality operator
172  bool operator==(const RGBColor& c) const;
173 
174  // @brief Inequality operator
175  bool operator!=(const RGBColor& c) const;
176 
179  static const RGBColor RED;
180  static const RGBColor GREEN;
181  static const RGBColor BLUE;
182  static const RGBColor YELLOW;
183  static const RGBColor CYAN;
184  static const RGBColor MAGENTA;
185  static const RGBColor ORANGE;
186  static const RGBColor WHITE;
187  static const RGBColor BLACK;
188  static const RGBColor GREY;
190 
192  static const RGBColor DEFAULT_COLOR;
193 
195  static const std::string DEFAULT_COLOR_STRING;
196 
197 private:
199  unsigned char myRed, myGreen, myBlue, myAlpha;
200 };
201 
202 
203 #endif
204 
205 /****************************************************************************/
206 
static const RGBColor BLUE
Definition: RGBColor.h:181
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:180
~RGBColor()
Destructor.
Definition: RGBColor.cpp:79
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:302
static const RGBColor WHITE
Definition: RGBColor.h:186
static RGBColor parseColorReporting(const std::string &coldef, const std::string &objecttype, const char *objectid, bool report, bool &ok)
Parses a color information.
Definition: RGBColor.cpp:260
bool operator==(const RGBColor &c) const
Definition: RGBColor.cpp:134
static const RGBColor ORANGE
Definition: RGBColor.h:185
friend std::ostream & operator<<(std::ostream &os, const RGBColor &col)
Writes the color to the given stream.
Definition: RGBColor.cpp:92
static const RGBColor BLACK
Definition: RGBColor.h:187
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:83
bool operator!=(const RGBColor &c) const
Definition: RGBColor.cpp:140
static const RGBColor GREEN
Definition: RGBColor.h:180
static const RGBColor GREY
Definition: RGBColor.h:188
unsigned char myAlpha
Definition: RGBColor.h:199
unsigned char myRed
The color amounts.
Definition: RGBColor.h:199
RGBColor invertedColor() const
obtain inverted of current RGBColor
Definition: RGBColor.cpp:146
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:192
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:90
unsigned char myGreen
Definition: RGBColor.h:199
static const RGBColor MAGENTA
Definition: RGBColor.h:184
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:157
static const RGBColor YELLOW
Definition: RGBColor.h:182
static const RGBColor RED
named colors
Definition: RGBColor.h:179
static const RGBColor CYAN
Definition: RGBColor.h:183
unsigned char myBlue
Definition: RGBColor.h:199
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:76
RGBColor()
Constructor.
Definition: RGBColor.cpp:67
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:69
static RGBColor interpolate(const RGBColor &minColor, const RGBColor &maxColor, double weight)
Interpolates between two colors.
Definition: RGBColor.cpp:286
static const std::string DEFAULT_COLOR_STRING
The string description of the default color.
Definition: RGBColor.h:195