LineColors.h
Go to the documentation of this file.
1 // LineColors.h
2 //
3 // David Adams
4 // February 2018
5 //
6 // Standard Root colors for lines and text, e.g. for drawing histograms.
7 //
8 // Developers may inherit from the class and redefine any color to
9 // their taste.
10 
11 #ifndef LineColors_H
12 #define LineColors_H
13 
14 #include "Rtypes.h"
15 
16 class LineColors {
17 
18 public:
19 
20  using ColorType = int;
21  using Index = unsigned int;
22 
23  // Return the colors.
24  static ColorType white() { return kWhite; };
25  static ColorType black() { return kBlack; };
26  static ColorType blue() { return kBlue + 2; }
27  static ColorType red() { return kRed + 1; }
28  static ColorType green() { return kGreen + 2; }
29  static ColorType brown() { return kOrange + 3; }
30  static ColorType violet() { return kMagenta + 1; }
31  static ColorType orange() { return kOrange - 3; }
32  static ColorType cyan() { return kCyan + 1; }
33  static ColorType yellow() { return kYellow - 7; }
34  static ColorType gray() { return kGray + 2; }
35  static ColorType purple() { return kViolet + 2; }
36  static ColorType lightGray() { return kGray + 0; }
37 
38  // Return the # "good" colors in the table.
39  static Index size() { return 8; }
40 
41  // Return the color for an index and color count.
42  // The colors repeat every ncol values.
43  static ColorType color(Index icolin, Index ncol =size()) {
44  Index icol = icolin;
45  if ( ncol > 0 ) icol = icolin%ncol;
46  if ( icol == 0 ) return blue();
47  if ( icol == 1 ) return red();
48  if ( icol == 2 ) return green();
49  if ( icol == 3 ) return brown();
50  if ( icol == 4 ) return violet();
51  if ( icol == 5 ) return orange();
52  if ( icol == 6 ) return cyan();
53  if ( icol == 7 ) return gray();
54  if ( icol == 8 ) return purple();
55  if ( icol == 9 ) return black();
56  if ( icol == 10 ) return yellow();
57  if ( icol == 11 ) return lightGray();
58  return white();
59  }
60 
61  // Return the color for an index using the default color count.
62  ColorType operator[](Index icolin) const { return color(icolin); }
63 
64 };
65 
66 #endif
static ColorType lightGray()
Definition: LineColors.h:36
ColorType operator[](Index icolin) const
Definition: LineColors.h:62
static ColorType blue()
Definition: LineColors.h:26
static ColorType orange()
Definition: LineColors.h:31
static Index size()
Definition: LineColors.h:39
static ColorType red()
Definition: LineColors.h:27
static ColorType cyan()
Definition: LineColors.h:32
static ColorType black()
Definition: LineColors.h:25
int ColorType
Definition: LineColors.h:20
static ColorType purple()
Definition: LineColors.h:35
static ColorType color(Index icolin, Index ncol=size())
Definition: LineColors.h:43
static ColorType green()
Definition: LineColors.h:28
static ColorType violet()
Definition: LineColors.h:30
unsigned int Index
Definition: LineColors.h:21
static ColorType yellow()
Definition: LineColors.h:33
static ColorType white()
Definition: LineColors.h:24
static ColorType gray()
Definition: LineColors.h:34
static ColorType brown()
Definition: LineColors.h:29