Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
palette.h
Go to the documentation of this file.
1 #ifndef PALETTE_H
2 #define PALETTE_H
3 
4 #include <QMap>
5 #include <QColor>
6 
7 namespace frechet { namespace view {
17 class Palette
18 {
19 private:
21  typedef QMap<size_t,QColor> ColorMap;
24 
26  QColor randomColor();
27 
31  QColor nextColor(size_t key);
32 
35  void stronger(QColor& col) {
36  if (col.hslSaturationF() < 0.5)
37  addLightness(col,+0.5);
38  }
39 
42  void weaker(QColor& col) {
43  if (col.hslSaturationF() > 0.5)
44  addLightness(col,-0.5);
45  }
46 
50  void addLightness(QColor& col, double diff) {
51  col.setHslF(col.hslHueF(), col.hslSaturationF()+diff, col.lightnessF(), col.alphaF());
52  }
53 
54 public:
56  Palette();
57 
61  QColor operator[] (size_t key);
62 
68  static QColor toColor(int x, int sat=220, int light=200);
69 
71  void clear();
72 };
73 
74 } } // namespace
75 
76 #endif // PALETTE_H
void weaker(QColor &col)
make the color a lighter saturation
Definition: palette.h:42
global definitions for all algorithms.
void addLightness(QColor &col, double diff)
modify the lightness of a color
Definition: palette.h:50
QColor nextColor(size_t key)
get color for a component; chose a new random color, if necessary
Definition: palette.cpp:20
void clear()
remove all entries from the map
Definition: palette.cpp:52
ColorMap map
the map
Definition: palette.h:23
void stronger(QColor &col)
make the color a darker saturation
Definition: palette.h:35
QMap< size_t, QColor > ColorMap
maps component IDs to random colors
Definition: palette.h:21
a color map.
Definition: palette.h:17
QColor operator[](size_t key)
look up a color
Definition: palette.cpp:38
static QColor toColor(int x, int sat=220, int light=200)
map an integer key to a color
Definition: palette.cpp:30
Palette()
constructor; creates an empty palette
Definition: palette.cpp:35