Advanced Strategic Command
colorizer.h
Go to the documentation of this file.
1 
2 
3 #ifndef colorizerH
4 #define colorizerH
5 
6 #include "surface.h"
7 
9 {
10 
11  class HSV
12  {
13  public:
14  int h;
15  int s;
16  int v;
17  HSV( int hh, int ss, int vv ) : h(hh), s(ss), v(vv) {};
18  HSV() : h(0), s(0), v(0) {};
19  };
20 
21  struct Cache {
22  DI_Color col[9][256][256];
23  };
24 
25  Cache* cache;
26 
27  static const int playerAngles[9];
28 
29  static const bool sat[9];
30 
31  void generate();
32 
33  HSV rgb2hsv( int r, int g);
34  DI_Color hsv2rgb( HSV hsv);
35 
36 
37  public:
38  ColorSwitch();
39 
40  inline DI_Color switchC( int player, int r, int g, int b) {
41  if ( g == b && r > g) {
42  if ( !cache )
43  generate();
44 
45  return cache->col[player][r][g];
46  } else {
47  return DI_Color(r,g,b);
48  }
49  }
50 };
51 
53 
54 #endif
A Device Independent color. Shamelessly pinched from Paragui to reduce coupling.
Definition: surface.h:30
ColorSwitch colorSwitch
Definition: colorizer.cpp:115
DI_Color switchC(int player, int r, int g, int b)
Definition: colorizer.h:40