ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TColor.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Rene Brun 12/12/94
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "Riostream.h"
13 #include "TROOT.h"
14 #include "TColor.h"
15 #include "TObjArray.h"
16 #include "TVirtualPad.h"
17 #include "TVirtualX.h"
18 #include "TError.h"
19 #include "TMathBase.h"
20 #include "TApplication.h"
21 #include <cmath>
22 
24 
25 namespace {
26  static Bool_t& TColor__GrayScaleMode() {
27  static Bool_t grayScaleMode;
28  return grayScaleMode;
29  }
30  static TArrayI& TColor__Palette() {
31  static TArrayI globalPalette(0);
32  return globalPalette;
33  }
34 }
35 
36 #define fgGrayscaleMode TColor__GrayScaleMode()
37 #define fgPalette TColor__Palette()
38 
39 using std::floor;
40 
41 /** \class TColor
42 The color creation and management class.
43 
44  - [Introduction](#C00)
45  - [Basic colors](#C01)
46  - [The color wheel](#C02)
47  - [Bright and dark colors](#C03)
48  - [Gray scale view of of canvas with colors](#C04)
49  - [Color palettes](#C05)
50  - [Color transparency](#C06)
51 
52 ## <a name="C00"></a> Introduction
53 
54 Colors are defined by their red, green and blue components, simply called the
55 RGB components. The colors are also known by the hue, light and saturation
56 components also known as the HLS components. When a new color is created the
57 components of both color systems are computed.
58 
59 At initialization time, a table of colors is generated. An existing color can
60 be retrieved by its index:
61 
62 ~~~ {.cpp}
63  TColor *color = gROOT->GetColor(10);
64 ~~~
65 
66 Then it can be manipulated. For example its RGB components can be modified:
67 
68 ~~~ {.cpp}
69  color->SetRGB(0.1, 0.2, 0.3);
70 ~~~
71 
72 A new color can be created the following way:
73 
74 ~~~ {.cpp}
75  Int_t ci = 1756; // color index
76  TColor *color = new TColor(ci, 0.1, 0.2, 0.3);
77 ~~~
78 
79 Two sets of colors are initialized;
80 
81  - The basic colors: colors with index from 0 to 50.
82  - The color wheel: colors with indices from 300 to 1000.
83 
84 ## <a name="C01"></a> Basic colors
85 The following image displays the 50 basic colors.
86 
87 Begin_Macro(source)
88 {
89  TCanvas *c = new TCanvas("c","Fill Area colors",0,0,500,200);
90  c->DrawColorTable();
91  return c;
92 }
93 End_Macro
94 
95 ## <a name="C02"></a> The color wheel
96 The wheel contains the recommended 216 colors to be used in web applications.
97 
98 The colors in the color wheel are created by `TColor::CreateColorWheel`.
99 
100 Using this color set for your text, background or graphics will give your
101 application a consistent appearance across different platforms and browsers.
102 
103 Colors are grouped by hue, the aspect most important in human perception.
104 Touching color chips have the same hue, but with different brightness and
105 vividness.
106 
107 Colors of slightly different hues <b>clash</b>. If you intend to display
108 colors of the same hue together, you should pick them from the same group.
109 
110 Each color chip is identified by a mnemonic (e.g. kYellow) and a number.
111 The keywords, kRed, kBlue, kYellow, kPink, etc are defined in the header file
112 <b>Rtypes.h</b> that is included in all ROOT other header files. It is better
113 to use these keywords in user code instead of hardcoded color numbers, e.g.:
114 ~~~ {.cpp}
115  myObject.SetFillColor(kRed);
116  myObject.SetFillColor(kYellow-10);
117  myLine.SetLineColor(kMagenta+2);
118 ~~~
119 
120 Begin_Macro(source)
121 {
122  TColorWheel *w = new TColorWheel();
123  w->Draw();
124  return w->GetCanvas();
125 }
126 End_Macro
127 
128 ## <a name="C03"></a> Bright and dark colors
129 The dark and bright color are used to give 3-D effects when drawing various
130 boxes (see TWbox, TPave, TPaveText, TPaveLabel, etc).
131 
132  - The dark colors have an index = color_index+100
133  - The bright colors have an index = color_index+150
134  - Two static functions return the bright and dark color number
135  corresponding to a color index. If the bright or dark color does not
136  exist, they are created:
137  ~~~ {.cpp}
138  Int_t dark = TColor::GetColorDark(color_index);
139  Int_t bright = TColor::GetColorBright(color_index);
140  ~~~
141 
142 ## <a name="C04"></a> Grayscale view of of canvas with colors
143 One can toggle between a grayscale preview and the regular colored mode using
144 `TCanvas::SetGrayscale()`. Note that in grayscale mode, access via RGB
145 will return grayscale values according to ITU standards (and close to b&w
146 printer gray-scales), while access via HLS returns de-saturated gray-scales. The
147 image below shows the ROOT color wheel in grayscale mode.
148 
149 Begin_Macro(source)
150 {
151  TColorWheel *w = new TColorWheel();
152  w->Draw();
153  w->GetCanvas()->SetGrayscale();
154  w->GetCanvas()->Modified();
155  w->GetCanvas()->Update();
156  return w->GetCanvas();
157 }
158 End_Macro
159 
160 ## <a name="C05"></a> Color palettes
161 It is often very useful to represent a variable with a color map. The concept
162 of "color palette" allows to do that. One color palette is active at any time.
163 This "current palette" is set using:
164 
165 ~~~ {.cpp}
166 gStyle->SetPalette(...);
167 ~~~
168 
169 This function has two parameters: the number of colors in the palette and an
170 array of containing the indices of colors in the palette. The following small
171 example demonstrates how to define and use the color palette:
172 
173 Begin_Macro(source)
174 {
175  TCanvas *c1 = new TCanvas("c1","c1",0,0,600,400);
176  TF2 *f1 = new TF2("f1","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",1,3,1,3);
177  Int_t palette[5];
178  palette[0] = 15;
179  palette[1] = 20;
180  palette[2] = 23;
181  palette[3] = 30;
182  palette[4] = 32;
183  gStyle->SetPalette(5,palette);
184  f1->Draw("colz");
185  return c1;
186 }
187 End_Macro
188 
189  To define more a complex palette with a continuous gradient of color, one
190 should use the static function `TColor::CreateGradientColorTable()`.
191 The following example demonstrates how to proceed:
192 
193 Begin_Macro(source)
194 {
195  TCanvas *c2 = new TCanvas("c2","c2",0,0,600,400);
196  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",1,3,1,3);
197  const Int_t Number = 3;
198  Double_t Red[Number] = { 1.00, 0.00, 0.00};
199  Double_t Green[Number] = { 0.00, 1.00, 0.00};
200  Double_t Blue[Number] = { 1.00, 0.00, 1.00};
201  Double_t Length[Number] = { 0.00, 0.50, 1.00 };
202  Int_t nb=50;
203  TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);
204  f2->SetContour(nb);
205  f2->SetLineWidth(1);
206  f2->SetLineColor(kBlack);
207  f2->Draw("surf1z");
208  return c2;
209 }
210 End_Macro
211 
212 The function `TColor::CreateGradientColorTable()` automatically
213 calls `gStyle->SetPalette()`, so there is not need to add one.
214 
215 After a call to `TColor::CreateGradientColorTable()` it is sometimes
216 useful to store the newly create palette for further use. In particular, it is
217 recommended to do if one wants to switch between several user define palettes.
218 To store a palette in an array it is enough to do:
219 
220 ~~~ {.cpp}
221  Int_t MyPalette[100];
222  Double_t r[] = {0., 0.0, 1.0, 1.0, 1.0};
223  Double_t g[] = {0., 0.0, 0.0, 1.0, 1.0};
224  Double_t b[] = {0., 1.0, 0.0, 0.0, 1.0};
225  Double_t stop[] = {0., .25, .50, .75, 1.0};
226  Int_t FI = TColor::CreateGradientColorTable(5, stop, r, g, b, 100);
227  for (int i=0;i<100;i++) MyPalette[i] = FI+i;
228 ~~~
229 
230 Later on to reuse the palette `MyPalette` it will be enough to do
231 
232 ~~~ {.cpp}
233  gStyle->SetPalette(100, MyPalette);
234 ~~~
235 
236 As only one palette is active, one need to use `TExec` to be able to
237 display plots using different palettes on the same pad.
238 The following macro illustrate this feature.
239 
240 Begin_Macro(source)
241 ../../../tutorials/graphs/multipalette.C
242 End_Macro
243 
244 ## <a name="C06"></a> Color transparency
245 To make a graphics object transparent it is enough to set its color to a
246 transparent one. The color transparency is defined via its alpha component. The
247 alpha value varies from `0.` (fully transparent) to `1.` (fully
248 opaque). To set the alpha value of an existing color it is enough to do:
249 
250 ~~~ {.cpp}
251  TColor *col26 = gROOT->GetColor(26);
252  col26->SetAlpha(0.01);
253 ~~~
254 
255 A new color can be created transparent the following way:
256 
257 ~~~ {.cpp}
258  Int_t ci = 1756;
259  TColor *color = new TColor(ci, 0.1, 0.2, 0.3, "", 0.5); // alpha = 0.5
260 ~~~
261 
262 An example of transparency usage with parallel coordinates can be found
263 in `$ROOTSYS/tutorials/tree/parallelcoordtrans.C`.
264 
265 To ease the creation of a transparent color the static method
266 `GetColorTransparent(Int_t color, Float_t a)` is provided.
267 In the following example the `trans_red` color index point to
268 a red color 30% transparent. The alpha value of the color index
269 `kRed` is not modified.
270 
271 ~~~ {.cpp}
272  Int_t trans_red = GetColorTransparent(kRed, 0.3);
273 ~~~
274 
275 This function is also used in the methods
276 `SetFillColorAlpha()`, `SetLineColorAlpha()`,
277 `SetMarkerColorAlpha()` and `SetTextColorAlpha()`.
278 In the following example the fill color of the histogram `histo`
279 is set to blue with a transparency of 35%. The color `kBlue`
280 itself remains fully opaque.
281 
282 ~~~ {.cpp}
283  histo->SetFillColorAlpha(kBlue, 0.35);
284 ~~~
285 
286 The transparency is available on all platforms when the `flagOpenGL.CanvasPreferGL` is set to `1`
287 in `$ROOTSYS/etc/system.rootrc`, or on Mac with the Cocoa backend. On the file output
288 it is visible with PDF, PNG, Gif, JPEG, SVG ... but not PostScript.
289  */
290 
291 ////////////////////////////////////////////////////////////////////////////////
292 /// Default constructor.
293 
295 {
296  fNumber = -1;
297  fRed = fGreen = fBlue = fHue = fLight = fSaturation = -1;
298  fAlpha = 1;
299 }
300 
301 ////////////////////////////////////////////////////////////////////////////////
302 /// Normal color constructor. Initialize a color structure.
303 /// Compute the RGB and HLS color components.
304 
305 TColor::TColor(Int_t color, Float_t r, Float_t g, Float_t b, const char *name,
307  : TNamed(name,"")
308 {
310  // do not enter if color number already exist
311  TColor *col = gROOT->GetColor(color);
312  if (col) {
313  Warning("TColor", "color %d already defined", color);
314  fNumber = col->GetNumber();
315  fRed = col->GetRed();
316  fGreen = col->GetGreen();
317  fBlue = col->GetBlue();
318  fHue = col->GetHue();
319  fLight = col->GetLight();
320  fAlpha = col->GetAlpha();
321  fSaturation = col->GetSaturation();
322  return;
323  }
324 
325  fNumber = color;
326 
327  char aname[32];
328  if (!name || !*name) {
329  snprintf(aname,32, "Color%d", color);
330  SetName(aname);
331  }
332 
333  // enter in the list of colors
334  TObjArray *lcolors = (TObjArray*)gROOT->GetListOfColors();
335  lcolors->AddAtAndExpand(this, color);
336 
337  // fill color structure
338  SetRGB(r, g, b);
339  fAlpha = a;
340 }
341 
342 ////////////////////////////////////////////////////////////////////////////////
343 /// Color destructor.
344 
346 {
347  gROOT->GetListOfColors()->Remove(this);
348  if (gROOT->GetListOfColors()->GetEntries() == 0) {fgPalette.Set(0); fgPalette=0;}
349 }
350 
351 ////////////////////////////////////////////////////////////////////////////////
352 /// Color copy constructor.
353 
354 TColor::TColor(const TColor &color) : TNamed(color)
355 {
356  ((TColor&)color).Copy(*this);
357 }
358 
359 ////////////////////////////////////////////////////////////////////////////////
360 /// Initialize colors used by the TCanvas based graphics (via TColor objects).
361 /// This method should be called before the ApplicationImp is created (which
362 /// initializes the GUI colors).
363 
365 {
366  static Bool_t initDone = kFALSE;
367 
368  if (initDone) return;
369  initDone = kTRUE;
370 
371  if (gROOT->GetListOfColors()->First() == 0) {
372 
373  new TColor(kWhite,1,1,1,"background");
374  new TColor(kBlack,0,0,0,"black");
375  new TColor(2,1,0,0,"red");
376  new TColor(3,0,1,0,"green");
377  new TColor(4,0,0,1,"blue");
378  new TColor(5,1,1,0,"yellow");
379  new TColor(6,1,0,1,"magenta");
380  new TColor(7,0,1,1,"cyan");
381  new TColor(10,0.999,0.999,0.999,"white");
382  new TColor(11,0.754,0.715,0.676,"editcol");
383 
384  // The color white above is defined as being nearly white.
385  // Sets the associated dark color also to white.
387  TColor *c110 = gROOT->GetColor(110);
388  if (c110) c110->SetRGB(0.999,0.999,.999);
389 
390  // Initialize Custom colors
391  new TColor(20,0.8,0.78,0.67);
392  new TColor(31,0.54,0.66,0.63);
393  new TColor(41,0.83,0.81,0.53);
394  new TColor(30,0.52,0.76,0.64);
395  new TColor(32,0.51,0.62,0.55);
396  new TColor(24,0.70,0.65,0.59);
397  new TColor(21,0.8,0.78,0.67);
398  new TColor(47,0.67,0.56,0.58);
399  new TColor(35,0.46,0.54,0.57);
400  new TColor(33,0.68,0.74,0.78);
401  new TColor(39,0.5,0.5,0.61);
402  new TColor(37,0.43,0.48,0.52);
403  new TColor(38,0.49,0.6,0.82);
404  new TColor(36,0.41,0.51,0.59);
405  new TColor(49,0.58,0.41,0.44);
406  new TColor(43,0.74,0.62,0.51);
407  new TColor(22,0.76,0.75,0.66);
408  new TColor(45,0.75,0.51,0.47);
409  new TColor(44,0.78,0.6,0.49);
410  new TColor(26,0.68,0.6,0.55);
411  new TColor(28,0.53,0.4,0.34);
412  new TColor(25,0.72,0.64,0.61);
413  new TColor(27,0.61,0.56,0.51);
414  new TColor(23,0.73,0.71,0.64);
415  new TColor(42,0.87,0.73,0.53);
416  new TColor(46,0.81,0.37,0.38);
417  new TColor(48,0.65,0.47,0.48);
418  new TColor(34,0.48,0.56,0.6);
419  new TColor(40,0.67,0.65,0.75);
420  new TColor(29,0.69,0.81,0.78);
421 
422  // Initialize some additional greyish non saturated colors
423  new TColor(8, 0.35,0.83,0.33);
424  new TColor(9, 0.35,0.33,0.85);
425  new TColor(12,.3,.3,.3,"grey12");
426  new TColor(13,.4,.4,.4,"grey13");
427  new TColor(14,.5,.5,.5,"grey14");
428  new TColor(15,.6,.6,.6,"grey15");
429  new TColor(16,.7,.7,.7,"grey16");
430  new TColor(17,.8,.8,.8,"grey17");
431  new TColor(18,.9,.9,.9,"grey18");
432  new TColor(19,.95,.95,.95,"grey19");
433  new TColor(50, 0.83,0.35,0.33);
434 
435  // Initialize the Pretty Palette Spectrum Violet->Red
436  // The color model used here is based on the HLS model which
437  // is much more suitable for creating palettes than RGB.
438  // Fixing the saturation and lightness we can scan through the
439  // spectrum of visible light by using "hue" alone.
440  // In Root hue takes values from 0 to 360.
441  Int_t i;
442  Float_t saturation = 1;
443  Float_t lightness = 0.5;
444  Float_t maxHue = 280;
445  Float_t minHue = 0;
446  Int_t maxPretty = 50;
447  Float_t hue;
448  Float_t r=0., g=0., b=0., h, l, s;
449 
450  for (i=0 ; i<maxPretty ; i++) {
451  hue = maxHue-(i+1)*((maxHue-minHue)/maxPretty);
452  TColor::HLStoRGB(hue, lightness, saturation, r, g, b);
453  new TColor(i+51, r, g, b);
454  }
455 
456  // Initialize special colors for x3d
457  TColor *s0;
458  for (i = 1; i < 8; i++) {
459  s0 = gROOT->GetColor(i);
460  if (s0) s0->GetRGB(r,g,b);
461  if (i == 1) { r = 0.6; g = 0.6; b = 0.6; }
462  if (r == 1) r = 0.9; if (r == 0) r = 0.1;
463  if (g == 1) g = 0.9; if (g == 0) g = 0.1;
464  if (b == 1) b = 0.9; if (b == 0) b = 0.1;
465  TColor::RGBtoHLS(r,g,b,h,l,s);
466  TColor::HLStoRGB(h,0.6*l,s,r,g,b);
467  new TColor(200+4*i-3,r,g,b);
468  TColor::HLStoRGB(h,0.8*l,s,r,g,b);
469  new TColor(200+4*i-2,r,g,b);
470  TColor::HLStoRGB(h,1.2*l,s,r,g,b);
471  new TColor(200+4*i-1,r,g,b);
472  TColor::HLStoRGB(h,1.4*l,s,r,g,b);
473  new TColor(200+4*i ,r,g,b);
474  }
475 
476  // Create the ROOT Color Wheel
478  }
479  // If fgPalette.fN !=0 SetPalette has been called already
480  // (from rootlogon.C for instance)
481 
482  if (!fgPalette.fN) SetPalette(1,0);
483 }
484 
485 ////////////////////////////////////////////////////////////////////////////////
486 /// Return color as hexadecimal string. This string can be directly passed
487 /// to, for example, TGClient::GetColorByName(). String will be reused so
488 /// copy immediately if needed.
489 
490 const char *TColor::AsHexString() const
491 {
492  static TString tempbuf;
493 
494  Int_t r, g, b, a;
495  r = Int_t(GetRed() * 255);
496  g = Int_t(GetGreen() * 255);
497  b = Int_t(GetBlue() * 255);
498  a = Int_t(fAlpha * 255);
499 
500  if (a != 255) {
501  tempbuf.Form("#%02x%02x%02x%02x", a, r, g, b);
502  } else {
503  tempbuf.Form("#%02x%02x%02x", r, g, b);
504  }
505  return tempbuf;
506 }
507 
508 ////////////////////////////////////////////////////////////////////////////////
509 /// Copy this color to obj.
510 
511 void TColor::Copy(TObject &obj) const
512 {
513  TNamed::Copy((TNamed&)obj);
514  ((TColor&)obj).fRed = fRed;
515  ((TColor&)obj).fGreen = fGreen;
516  ((TColor&)obj).fBlue = fBlue;
517  ((TColor&)obj).fHue = fHue;
518  ((TColor&)obj).fLight = fLight;
519  ((TColor&)obj).fAlpha = fAlpha;
520  ((TColor&)obj).fSaturation = fSaturation;
521  ((TColor&)obj).fNumber = fNumber;
522 }
523 
524 ////////////////////////////////////////////////////////////////////////////////
525 /// Create the Gray scale colors in the Color Wheel
526 
528 {
529  if (gROOT->GetColor(kGray)) return;
530  TColor *gray = new TColor(kGray,204./255.,204./255.,204./255.);
531  TColor *gray1 = new TColor(kGray+1,153./255.,153./255.,153./255.);
532  TColor *gray2 = new TColor(kGray+2,102./255.,102./255.,102./255.);
533  TColor *gray3 = new TColor(kGray+3, 51./255., 51./255., 51./255.);
534  gray ->SetName("kGray");
535  gray1->SetName("kGray+1");
536  gray2->SetName("kGray+2");
537  gray3->SetName("kGray+3");
538 }
539 
540 ////////////////////////////////////////////////////////////////////////////////
541 /// Create the "circle" colors in the color wheel.
542 
543 void TColor::CreateColorsCircle(Int_t offset, const char *name, UChar_t *rgb)
544 {
545  TString colorname;
546  for (Int_t n=0;n<15;n++) {
547  Int_t colorn = offset+n-10;
548  TColor *color = gROOT->GetColor(colorn);
549  if (!color) {
550  color = new TColor(colorn,rgb[3*n]/255.,rgb[3*n+1]/255.,rgb[3*n+2]/255.);
551  color->SetTitle(color->AsHexString());
552  if (n>10) colorname.Form("%s+%d",name,n-10);
553  else if (n<10) colorname.Form("%s-%d",name,10-n);
554  else colorname.Form("%s",name);
555  color->SetName(colorname);
556  }
557  }
558 }
559 
560 ////////////////////////////////////////////////////////////////////////////////
561 /// Create the "rectangular" colors in the color wheel.
562 
563 void TColor::CreateColorsRectangle(Int_t offset, const char *name, UChar_t *rgb)
564 {
565  TString colorname;
566  for (Int_t n=0;n<20;n++) {
567  Int_t colorn = offset+n-9;
568  TColor *color = gROOT->GetColor(colorn);
569  if (!color) {
570  color = new TColor(colorn,rgb[3*n]/255.,rgb[3*n+1]/255.,rgb[3*n+2]/255.);
571  color->SetTitle(color->AsHexString());
572  if (n>9) colorname.Form("%s+%d",name,n-9);
573  else if (n<9) colorname.Form("%s-%d",name,9-n);
574  else colorname.Form("%s",name);
575  color->SetName(colorname);
576  }
577  }
578 }
579 
580 ////////////////////////////////////////////////////////////////////////////////
581 /// Static function steering the creation of all colors in the color wheel.
582 
584 {
585  UChar_t magenta[46]= {255,204,255
586  ,255,153,255, 204,153,204
587  ,255,102,255, 204,102,204, 153,102,153
588  ,255, 51,255, 204, 51,204, 153, 51,153, 102, 51,102
589  ,255, 0,255, 204, 0,204, 153, 0,153, 102, 0,102, 51, 0, 51};
590 
591  UChar_t red[46] = {255,204,204
592  ,255,153,153, 204,153,153
593  ,255,102,102, 204,102,102, 153,102,102
594  ,255, 51, 51, 204, 51, 51, 153, 51, 51, 102, 51, 51
595  ,255, 0, 0, 204, 0, 0, 153, 0, 0, 102, 0, 0, 51, 0, 0};
596 
597  UChar_t yellow[46] = {255,255,204
598  ,255,255,153, 204,204,153
599  ,255,255,102, 204,204,102, 153,153,102
600  ,255,255, 51, 204,204, 51, 153,153, 51, 102,102, 51
601  ,255,255, 0, 204,204, 0, 153,153, 0, 102,102, 0, 51, 51, 0};
602 
603  UChar_t green[46] = {204,255,204
604  ,153,255,153, 153,204,153
605  ,102,255,102, 102,204,102, 102,153,102
606  , 51,255, 51, 51,204, 51, 51,153, 51, 51,102, 51
607  , 0,255, 0, 0,204, 0, 0,153, 0, 0,102, 0, 0, 51, 0};
608 
609  UChar_t cyan[46] = {204,255,255
610  ,153,255,255, 153,204,204
611  ,102,255,255, 102,204,204, 102,153,153
612  , 51,255,255, 51,204,204, 51,153,153, 51,102,102
613  , 0,255,255, 0,204,204, 0,153,153, 0,102,102, 0, 51, 51};
614 
615  UChar_t blue[46] = {204,204,255
616  ,153,153,255, 153,153,204
617  ,102,102,255, 102,102,204, 102,102,153
618  , 51, 51,255, 51, 51,204, 51, 51,153, 51, 51,102
619  , 0, 0,255, 0, 0,204, 0, 0,153, 0, 0,102, 0, 0, 51};
620 
621  UChar_t pink[60] = {255, 51,153, 204, 0,102, 102, 0, 51, 153, 0, 51, 204, 51,102
622  ,255,102,153, 255, 0,102, 255, 51,102, 204, 0, 51, 255, 0, 51
623  ,255,153,204, 204,102,153, 153, 51,102, 153, 0,102, 204, 51,153
624  ,255,102,204, 255, 0,153, 204, 0,153, 255, 51,204, 255, 0,153};
625 
626  UChar_t orange[60]={255,204,153, 204,153,102, 153,102, 51, 153,102, 0, 204,153, 51
627  ,255,204,102, 255,153, 0, 255,204, 51, 204,153, 0, 255,204, 0
628  ,255,153, 51, 204,102, 0, 102, 51, 0, 153, 51, 0, 204,102, 51
629  ,255,153,102, 255,102, 0, 255,102, 51, 204, 51, 0, 255, 51, 0};
630 
631  UChar_t spring[60]={153,255, 51, 102,204, 0, 51,102, 0, 51,153, 0, 102,204, 51
632  ,153,255,102, 102,255, 0, 102,255, 51, 51,204, 0, 51,255, 0
633  ,204,255,153, 153,204,102, 102,153, 51, 102,153, 0, 153,204, 51
634  ,204,255,102, 153,255, 0, 204,255, 51, 153,204, 0, 204,255, 0};
635 
636  UChar_t teal[60] = {153,255,204, 102,204,153, 51,153,102, 0,153,102, 51,204,153
637  ,102,255,204, 0,255,102, 51,255,204, 0,204,153, 0,255,204
638  , 51,255,153, 0,204,102, 0,102, 51, 0,153, 51, 51,204,102
639  ,102,255,153, 0,255,153, 51,255,102, 0,204, 51, 0,255, 51};
640 
641  UChar_t azure[60] ={153,204,255, 102,153,204, 51,102,153, 0, 51,153, 51,102,204
642  ,102,153,255, 0,102,255, 51,102,255, 0, 51,204, 0, 51,255
643  , 51,153,255, 0,102,204, 0, 51,102, 0,102,153, 51,153,204
644  ,102,204,255, 0,153,255, 51,204,255, 0,153,204, 0,204,255};
645 
646  UChar_t violet[60]={204,153,255, 153,102,204, 102, 51,153, 102, 0,153, 153, 51,204
647  ,204,102,255, 153, 0,255, 204, 51,255, 153, 0,204, 204, 0,255
648  ,153, 51,255, 102, 0,204, 51, 0,102, 51, 0,153, 102, 51,204
649  ,153,102,255, 102, 0,255, 102, 51,255, 51, 0,204, 51, 0,255};
650 
651  TColor::CreateColorsCircle(kMagenta,"kMagenta",magenta);
652  TColor::CreateColorsCircle(kRed, "kRed", red);
653  TColor::CreateColorsCircle(kYellow, "kYellow", yellow);
654  TColor::CreateColorsCircle(kGreen, "kGreen", green);
655  TColor::CreateColorsCircle(kCyan, "kCyan", cyan);
656  TColor::CreateColorsCircle(kBlue, "kBlue", blue);
657 
658  TColor::CreateColorsRectangle(kPink, "kPink", pink);
659  TColor::CreateColorsRectangle(kOrange,"kOrange",orange);
660  TColor::CreateColorsRectangle(kSpring,"kSpring",spring);
661  TColor::CreateColorsRectangle(kTeal, "kTeal", teal);
662  TColor::CreateColorsRectangle(kAzure, "kAzure", azure);
663  TColor::CreateColorsRectangle(kViolet,"kViolet",violet);
664 
666 }
667 
668 ////////////////////////////////////////////////////////////////////////////////
669 /// Static function returning the color number i in current palette.
670 
672 {
673  Int_t ncolors = fgPalette.fN;
674  if (ncolors == 0) return 0;
675  Int_t icol = i%ncolors;
676  if (icol < 0) icol = 0;
677  return fgPalette.fArray[icol];
678 }
679 
680 ////////////////////////////////////////////////////////////////////////////////
681 /// Static function returning number of colors in the color palette.
682 
684 {
685  return fgPalette.fN;
686 }
687 
688 ////////////////////////////////////////////////////////////////////////////////
689 /// Return pixel value corresponding to this color. This pixel value can
690 /// be used in the GUI classes. This call does not work in batch mode since
691 /// it needs to communicate with the graphics system.
692 
694 {
695  if (gVirtualX && !gROOT->IsBatch()) {
696  if (gApplication) {
699  }
700  return gVirtualX->GetPixel(fNumber);
701  }
702 
703  return 0;
704 }
705 
706 ////////////////////////////////////////////////////////////////////////////////
707 /// Static method to compute RGB from HLS. The l and s are between [0,1]
708 /// and h is between [0,360]. The returned r,g,b triplet is between [0,1].
709 
710 void TColor::HLS2RGB(Float_t hue, Float_t light, Float_t satur,
712 {
713 
714  Float_t rh, rl, rs, rm1, rm2;
715  rh = rl = rs = 0;
716  if (hue > 0) rh = hue; if (rh > 360) rh = 360;
717  if (light > 0) rl = light; if (rl > 1) rl = 1;
718  if (satur > 0) rs = satur; if (rs > 1) rs = 1;
719 
720  if (rl <= 0.5)
721  rm2 = rl*(1.0 + rs);
722  else
723  rm2 = rl + rs - rl*rs;
724  rm1 = 2.0*rl - rm2;
725 
726  if (!rs) { r = rl; g = rl; b = rl; return; }
727  r = HLStoRGB1(rm1, rm2, rh+120);
728  g = HLStoRGB1(rm1, rm2, rh);
729  b = HLStoRGB1(rm1, rm2, rh-120);
730 }
731 
732 ////////////////////////////////////////////////////////////////////////////////
733 /// Static method. Auxiliary to HLS2RGB().
734 
736 {
737  Float_t hue = huei;
738  if (hue > 360) hue = hue - 360;
739  if (hue < 0) hue = hue + 360;
740  if (hue < 60 ) return rn1 + (rn2-rn1)*hue/60;
741  if (hue < 180) return rn2;
742  if (hue < 240) return rn1 + (rn2-rn1)*(240-hue)/60;
743  return rn1;
744 }
745 
746 ////////////////////////////////////////////////////////////////////////////////
747 /// Static method to compute RGB from HLS. The h,l,s are between [0,255].
748 /// The returned r,g,b triplet is between [0,255].
749 
750 void TColor::HLS2RGB(Int_t h, Int_t l, Int_t s, Int_t &r, Int_t &g, Int_t &b)
751 {
752  Float_t hh, ll, ss, rr, gg, bb;
753 
754  hh = Float_t(h) * 360 / 255;
755  ll = Float_t(l) / 255;
756  ss = Float_t(s) / 255;
757 
758  TColor::HLStoRGB(hh, ll, ss, rr, gg, bb);
759 
760  r = (Int_t) (rr * 255);
761  g = (Int_t) (gg * 255);
762  b = (Int_t) (bb * 255);
763 }
764 
765 ////////////////////////////////////////////////////////////////////////////////
766 /// Static method to compute RGB from HSV:
767 ///
768 /// - The hue value runs from 0 to 360.
769 /// - The saturation is the degree of strength or purity and is from 0 to 1.
770 /// Purity is how much white is added to the color, so S=1 makes the purest
771 /// color (no white).
772 /// - Brightness value also ranges from 0 to 1, where 0 is the black.
773 ///
774 /// The returned r,g,b triplet is between [0,1].
775 
776 void TColor::HSV2RGB(Float_t hue, Float_t satur, Float_t value,
778 {
779  Int_t i;
780  Float_t f, p, q, t;
781 
782  if (satur==0) {
783  // Achromatic (grey)
784  r = g = b = value;
785  return;
786  }
787 
788  hue /= 60; // sector 0 to 5
789  i = (Int_t)floor(hue);
790  f = hue-i; // factorial part of hue
791  p = value*(1-satur);
792  q = value*(1-satur*f );
793  t = value*(1-satur*(1-f));
794 
795  switch (i) {
796  case 0:
797  r = value;
798  g = t;
799  b = p;
800  break;
801  case 1:
802  r = q;
803  g = value;
804  b = p;
805  break;
806  case 2:
807  r = p;
808  g = value;
809  b = t;
810  break;
811  case 3:
812  r = p;
813  g = q;
814  b = value;
815  break;
816  case 4:
817  r = t;
818  g = p;
819  b = value;
820  break;
821  default:
822  r = value;
823  g = p;
824  b = q;
825  break;
826  }
827 }
828 
829 ////////////////////////////////////////////////////////////////////////////////
830 /// List this color with its attributes.
831 
832 void TColor::ls(Option_t *) const
833 {
834  printf("Color:%d Red=%f Green=%f Blue=%f Name=%s\n",
836 }
837 
838 ////////////////////////////////////////////////////////////////////////////////
839 /// Dump this color with its attributes.
840 
841 void TColor::Print(Option_t *) const
842 {
843  ls();
844 }
845 
846 ////////////////////////////////////////////////////////////////////////////////
847 /// Static method to compute HLS from RGB. The r,g,b triplet is between
848 /// [0,1], hue is between [0,360], light and satur are [0,1].
849 
850 void TColor::RGB2HLS(Float_t rr, Float_t gg, Float_t bb,
851  Float_t &hue, Float_t &light, Float_t &satur)
852 {
853  Float_t rnorm, gnorm, bnorm, minval, maxval, msum, mdiff, r, g, b;
854  minval = maxval =0 ;
855  r = g = b = 0;
856  if (rr > 0) r = rr; if (r > 1) r = 1;
857  if (gg > 0) g = gg; if (g > 1) g = 1;
858  if (bb > 0) b = bb; if (b > 1) b = 1;
859 
860  minval = r;
861  if (g < minval) minval = g;
862  if (b < minval) minval = b;
863  maxval = r;
864  if (g > maxval) maxval = g;
865  if (b > maxval) maxval = b;
866 
867  rnorm = gnorm = bnorm = 0;
868  mdiff = maxval - minval;
869  msum = maxval + minval;
870  light = 0.5 * msum;
871  if (maxval != minval) {
872  rnorm = (maxval - r)/mdiff;
873  gnorm = (maxval - g)/mdiff;
874  bnorm = (maxval - b)/mdiff;
875  } else {
876  satur = hue = 0;
877  return;
878  }
879 
880  if (light < 0.5)
881  satur = mdiff/msum;
882  else
883  satur = mdiff/(2.0 - msum);
884 
885  if (r == maxval)
886  hue = 60.0 * (6.0 + bnorm - gnorm);
887  else if (g == maxval)
888  hue = 60.0 * (2.0 + rnorm - bnorm);
889  else
890  hue = 60.0 * (4.0 + gnorm - rnorm);
891 
892  if (hue > 360)
893  hue = hue - 360;
894 }
895 
896 ////////////////////////////////////////////////////////////////////////////////
897 /// Static method to compute HSV from RGB.
898 ///
899 /// - The input values:
900 /// - r,g,b triplet is between [0,1].
901 /// - The returned values:
902 /// - The hue value runs from 0 to 360.
903 /// - The saturation is the degree of strength or purity and is from 0 to 1.
904 /// Purity is how much white is added to the color, so S=1 makes the purest
905 /// color (no white).
906 /// - Brightness value also ranges from 0 to 1, where 0 is the black.
907 
909  Float_t &hue, Float_t &satur, Float_t &value)
910 {
911  Float_t min, max, delta;
912 
913  min = TMath::Min(TMath::Min(r, g), b);
914  max = TMath::Max(TMath::Max(r, g), b);
915  value = max;
916 
917  delta = max - min;
918 
919  if (max != 0) {
920  satur = delta/max;
921  } else {
922  satur = 0;
923  hue = -1;
924  return;
925  }
926 
927  if (r == max) {
928  hue = (g-b)/delta;
929  } else if (g == max) {
930  hue = 2+(b-r)/delta;
931  } else {
932  hue = 4+(r-g)/delta;
933  }
934 
935  hue *= 60;
936  if (hue < 0) hue += 360;
937 }
938 
939 ////////////////////////////////////////////////////////////////////////////////
940 /// Static method to compute HLS from RGB. The r,g,b triplet is between
941 /// [0,255], hue, light and satur are between [0,255].
942 
943 void TColor::RGB2HLS(Int_t r, Int_t g, Int_t b, Int_t &h, Int_t &l, Int_t &s)
944 {
945  Float_t rr, gg, bb, hue, light, satur;
946 
947  rr = Float_t(r) / 255;
948  gg = Float_t(g) / 255;
949  bb = Float_t(b) / 255;
950 
951  TColor::RGBtoHLS(rr, gg, bb, hue, light, satur);
952 
953  h = (Int_t) (hue/360 * 255);
954  l = (Int_t) (light * 255);
955  s = (Int_t) (satur * 255);
956 }
957 
958 ////////////////////////////////////////////////////////////////////////////////
959 /// Initialize this color and its associated colors.
960 
962 {
964  fRed = r;
965  fGreen = g;
966  fBlue = b;
967 
968  if (fRed < 0) return;
969 
970  RGBtoHLS(r, g, b, fHue, fLight, fSaturation);
971 
972  Int_t nplanes = 16;
973  if (gVirtualX) gVirtualX->GetPlanes(nplanes);
974  if (nplanes == 0) nplanes = 16;
975 
976  // allocate color now (can be delayed when we have a large colormap)
977 #ifndef R__WIN32
978  if (nplanes < 15)
979 #endif
980  Allocate();
981 
982  if (fNumber > 50) return;
983 
984  // now define associated colors for WBOX shading
985  Float_t dr, dg, db, lr, lg, lb;
986 
987  // set dark color
988  HLStoRGB(fHue, 0.7*fLight, fSaturation, dr, dg, db);
989  TColor *dark = gROOT->GetColor(100+fNumber);
990  if (dark) {
991  if (nplanes > 8) dark->SetRGB(dr, dg, db);
992  else dark->SetRGB(0.3,0.3,0.3);
993  }
994 
995  // set light color
996  HLStoRGB(fHue, 1.2*fLight, fSaturation, lr, lg, lb);
997  TColor *light = gROOT->GetColor(150+fNumber);
998  if (light) {
999  if (nplanes > 8) light->SetRGB(lr, lg, lb);
1000  else light->SetRGB(0.8,0.8,0.8);
1001  }
1002 }
1003 
1004 ////////////////////////////////////////////////////////////////////////////////
1005 /// Make this color known to the graphics system.
1006 
1007 void TColor::Allocate()
1009  if (gVirtualX && !gROOT->IsBatch())
1010 
1011  gVirtualX->SetRGB(fNumber, GetRed(), GetGreen(), GetBlue());
1012 }
1013 
1014 ////////////////////////////////////////////////////////////////////////////////
1015 /// Static method returning color number for color specified by
1016 /// hex color string of form: "#rrggbb", where rr, gg and bb are in
1017 /// hex between [0,FF], e.g. "#c0c0c0".
1018 ///
1019 /// If specified color does not exist it will be created with as
1020 /// name "#rrggbb" with rr, gg and bb in hex between [0,FF].
1021 
1022 Int_t TColor::GetColor(const char *hexcolor)
1024  if (hexcolor && *hexcolor == '#') {
1025  Int_t r, g, b;
1026  if (sscanf(hexcolor+1, "%02x%02x%02x", &r, &g, &b) == 3)
1027  return GetColor(r, g, b);
1028  }
1029  ::Error("TColor::GetColor(const char*)", "incorrect color string");
1030  return 0;
1031 }
1032 
1033 ////////////////////////////////////////////////////////////////////////////////
1034 /// Static method returning color number for color specified by
1035 /// r, g and b. The r,g,b should be in the range [0,1].
1036 ///
1037 /// If specified color does not exist it will be created
1038 /// with as name "#rrggbb" with rr, gg and bb in hex between
1039 /// [0,FF].
1040 
1043  Int_t rr, gg, bb;
1044  rr = Int_t(r * 255);
1045  gg = Int_t(g * 255);
1046  bb = Int_t(b * 255);
1047 
1048  return GetColor(rr, gg, bb);
1049 }
1050 
1051 ////////////////////////////////////////////////////////////////////////////////
1052 /// Static method returning color number for color specified by
1053 /// system dependent pixel value. Pixel values can be obtained, e.g.,
1054 /// from the GUI color picker.
1055 
1058  Int_t r, g, b;
1059 
1060  Pixel2RGB(pixel, r, g, b);
1061 
1062  return GetColor(r, g, b);
1063 }
1064 
1065 ////////////////////////////////////////////////////////////////////////////////
1066 /// Static method returning color number for color specified by
1067 /// r, g and b. The r,g,b should be in the range [0,255].
1068 /// If the specified color does not exist it will be created
1069 /// with as name "#rrggbb" with rr, gg and bb in hex between
1070 /// [0,FF].
1071 
1075  if (r < 0) r = 0;
1076  if (g < 0) g = 0;
1077  if (b < 0) b = 0;
1078  if (r > 255) r = 255;
1079  if (g > 255) g = 255;
1080  if (b > 255) b = 255;
1081 
1082  // Get list of all defined colors
1083  TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
1084 
1085  TColor *color = 0;
1086 
1087  // Look for color by name
1088  if ((color = (TColor*)colors->FindObject(Form("#%02x%02x%02x", r, g, b))))
1089  // We found the color by name, so we use that right away
1090  return color->GetNumber();
1091 
1092  Float_t rr, gg, bb;
1093  rr = Float_t(r)/255.;
1094  gg = Float_t(g)/255.;
1095  bb = Float_t(b)/255.;
1096 
1097  TIter next(colors);
1098 
1099  Int_t nplanes = 16;
1100  Float_t thres = 1.0/31.0; // 5 bits per color : 0 - 0x1F !
1101  if (gVirtualX) gVirtualX->GetPlanes(nplanes);
1102  if (nplanes >= 24)
1103  thres = 1.0/255.0; // 8 bits per color : 0 - 0xFF !
1104 
1105  // Loop over all defined colors
1106  while ((color = (TColor*)next())) {
1107  if (TMath::Abs(color->GetRed() - rr) > thres)
1108  continue;
1109  if (TMath::Abs(color->GetGreen() - gg) > thres)
1110  continue;
1111  if (TMath::Abs(color->GetBlue() - bb) > thres)
1112  continue;
1113 
1114  // We found a matching color in the color table
1115  return color->GetNumber();
1116  }
1117 
1118  // We didn't find a matching color in the color table, so we
1119  // add it. Note name is of the form "#rrggbb" where rr, etc. are
1120  // hexadecimal numbers.
1121  color = new TColor(colors->GetLast()+1, rr, gg, bb,
1122  Form("#%02x%02x%02x", r, g, b));
1123 
1124  return color->GetNumber();
1125 }
1126 
1127 ////////////////////////////////////////////////////////////////////////////////
1128 /// Static function: Returns the bright color number corresponding to n
1129 /// If the TColor object does not exist, it is created.
1130 /// The convention is that the bright color nb = n+150
1131 
1134  if (n < 0) return -1;
1135 
1136  // Get list of all defined colors
1137  TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
1138  Int_t ncolors = colors->GetSize();
1139  // Get existing color at index n
1140  TColor *color = 0;
1141  if (n < ncolors) color = (TColor*)colors->At(n);
1142  if (!color) return -1;
1143 
1144  //Get the rgb of the the new bright color corresponding to color n
1145  Float_t r,g,b;
1146  HLStoRGB(color->GetHue(), 1.2*color->GetLight(), color->GetSaturation(), r, g, b);
1147 
1148  //Build the bright color (unless the slot nb is already used)
1149  Int_t nb = n+150;
1150  TColor *colorb = 0;
1151  if (nb < ncolors) colorb = (TColor*)colors->At(nb);
1152  if (colorb) return nb;
1153  colorb = new TColor(nb,r,g,b);
1154  colorb->SetName(Form("%s_bright",color->GetName()));
1155  colors->AddAtAndExpand(colorb,nb);
1156  return nb;
1157 }
1158 
1159 ////////////////////////////////////////////////////////////////////////////////
1160 /// Static function: Returns the dark color number corresponding to n
1161 /// If the TColor object does not exist, it is created.
1162 /// The convention is that the dark color nd = n+100
1163 
1166  if (n < 0) return -1;
1167 
1168  // Get list of all defined colors
1169  TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
1170  Int_t ncolors = colors->GetSize();
1171  // Get existing color at index n
1172  TColor *color = 0;
1173  if (n < ncolors) color = (TColor*)colors->At(n);
1174  if (!color) return -1;
1175 
1176  //Get the rgb of the the new dark color corresponding to color n
1177  Float_t r,g,b;
1178  HLStoRGB(color->GetHue(), 0.7*color->GetLight(), color->GetSaturation(), r, g, b);
1179 
1180  //Build the dark color (unless the slot nd is already used)
1181  Int_t nd = n+100;
1182  TColor *colord = 0;
1183  if (nd < ncolors) colord = (TColor*)colors->At(nd);
1184  if (colord) return nd;
1185  colord = new TColor(nd,r,g,b);
1186  colord->SetName(Form("%s_dark",color->GetName()));
1187  colors->AddAtAndExpand(colord,nd);
1188  return nd;
1189 }
1190 
1191 ////////////////////////////////////////////////////////////////////////////////
1192 /// Static function: Returns the transparent color number corresponding to n.
1193 /// The transparency level is given by the alpha value a.
1194 
1197  if (n < 0) return -1;
1198 
1199  TColor *color = gROOT->GetColor(n);
1200  if (color) {
1201  TColor *colort = new TColor(gROOT->GetListOfColors()->GetLast()+1,
1202  color->GetRed(), color->GetGreen(), color->GetBlue());
1203  colort->SetAlpha(a);
1204  colort->SetName(Form("%s_transparent",color->GetName()));
1205  return colort->GetNumber();
1206  } else {
1207  ::Error("TColor::GetColorTransparent", "color with index %d not defined", n);
1208  return -1;
1209  }
1210 }
1211 
1212 ////////////////////////////////////////////////////////////////////////////////
1213 /// Static method that given a color index number, returns the corresponding
1214 /// pixel value. This pixel value can be used in the GUI classes. This call
1215 /// does not work in batch mode since it needs to communicate with the
1216 /// graphics system.
1217 
1221  TColor *color = gROOT->GetColor(ci);
1222  if (color)
1223  return color->GetPixel();
1224  else
1225  ::Warning("TColor::Number2Pixel", "color with index %d not defined", ci);
1226 
1227  return 0;
1228 }
1229 
1230 ////////////////////////////////////////////////////////////////////////////////
1231 /// Convert r,g,b to graphics system dependent pixel value.
1232 /// The r,g,b triplet must be [0,1].
1233 
1236  if (r < 0) r = 0;
1237  if (g < 0) g = 0;
1238  if (b < 0) b = 0;
1239  if (r > 1) r = 1;
1240  if (g > 1) g = 1;
1241  if (b > 1) b = 1;
1242 
1243  ColorStruct_t color;
1244  color.fRed = UShort_t(r * 65535);
1245  color.fGreen = UShort_t(g * 65535);
1246  color.fBlue = UShort_t(b * 65535);
1247  color.fMask = kDoRed | kDoGreen | kDoBlue;
1248  gVirtualX->AllocColor(gVirtualX->GetColormap(), color);
1249  return color.fPixel;
1250 }
1251 
1252 ////////////////////////////////////////////////////////////////////////////////
1253 /// Convert r,g,b to graphics system dependent pixel value.
1254 /// The r,g,b triplet must be [0,255].
1255 
1258  if (r < 0) r = 0;
1259  if (g < 0) g = 0;
1260  if (b < 0) b = 0;
1261  if (r > 255) r = 255;
1262  if (g > 255) g = 255;
1263  if (b > 255) b = 255;
1264 
1265  ColorStruct_t color;
1266  color.fRed = UShort_t(r * 257); // 65535/255
1267  color.fGreen = UShort_t(g * 257);
1268  color.fBlue = UShort_t(b * 257);
1269  color.fMask = kDoRed | kDoGreen | kDoBlue;
1270  gVirtualX->AllocColor(gVirtualX->GetColormap(), color);
1271  return color.fPixel;
1272 }
1273 
1274 ////////////////////////////////////////////////////////////////////////////////
1275 /// Convert machine dependent pixel value (obtained via RGB2Pixel or
1276 /// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet.
1277 /// The r,g,b triplet will be [0,1].
1278 
1279 void TColor::Pixel2RGB(ULong_t pixel, Float_t &r, Float_t &g, Float_t &b)
1281  ColorStruct_t color;
1282  color.fPixel = pixel;
1283  gVirtualX->QueryColor(gVirtualX->GetColormap(), color);
1284  r = (Float_t)color.fRed / 65535;
1285  g = (Float_t)color.fGreen / 65535;
1286  b = (Float_t)color.fBlue / 65535;
1287 }
1288 
1289 ////////////////////////////////////////////////////////////////////////////////
1290 /// Convert machine dependent pixel value (obtained via RGB2Pixel or
1291 /// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet.
1292 /// The r,g,b triplet will be [0,255].
1293 
1294 void TColor::Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b)
1296  ColorStruct_t color;
1297  color.fPixel = pixel;
1298  gVirtualX->QueryColor(gVirtualX->GetColormap(), color);
1299  r = color.fRed / 257;
1300  g = color.fGreen / 257;
1301  b = color.fBlue / 257;
1302 }
1303 
1304 ////////////////////////////////////////////////////////////////////////////////
1305 /// Convert machine dependent pixel value (obtained via RGB2Pixel or
1306 /// via Number2Pixel() or via TColor::GetPixel()) to a hexadecimal string.
1307 /// This string can be directly passed to, for example,
1308 /// TGClient::GetColorByName(). String will be reused so copy immediately
1309 /// if needed.
1310 
1311 const char *TColor::PixelAsHexString(ULong_t pixel)
1313  static TString tempbuf;
1314  Int_t r, g, b;
1315  Pixel2RGB(pixel, r, g, b);
1316  tempbuf.Form("#%02x%02x%02x", r, g, b);
1317  return tempbuf;
1318 }
1319 
1320 ////////////////////////////////////////////////////////////////////////////////
1321 /// Save a color with index > 228 as a C++ statement(s) on output stream out.
1322 
1323 void TColor::SaveColor(std::ostream &out, Int_t ci)
1325  char quote = '"';
1326  Float_t r,g,b,a;
1327  Int_t ri, gi, bi;
1328  TString cname;
1329 
1330  TColor *c = gROOT->GetColor(ci);
1331  if (c) {
1332  c->GetRGB(r, g, b);
1333  a = c->GetAlpha();
1334  } else {
1335  return;
1336  }
1337 
1338  if (gROOT->ClassSaved(TColor::Class())) {
1339  out << std::endl;
1340  } else {
1341  out << std::endl;
1342  out << " Int_t ci; // for color index setting" << std::endl;
1343  out << " TColor *color; // for color definition with alpha" << std::endl;
1344  }
1345 
1346  if (a<1) {
1347  out<<" ci = "<<ci<<";"<<std::endl;
1348  out<<" color = new TColor(ci, "<<r<<", "<<g<<", "<<b<<", "
1349  <<"\" \", "<<a<<");"<<std::endl;
1350  } else {
1351  ri = (Int_t)(255*r);
1352  gi = (Int_t)(255*g);
1353  bi = (Int_t)(255*b);
1354  cname.Form("#%02x%02x%02x", ri, gi, bi);
1355  out<<" ci = TColor::GetColor("<<quote<<cname.Data()<<quote<<");"<<std::endl;
1356  }
1357 }
1358 
1359 ////////////////////////////////////////////////////////////////////////////////
1360 /// Return whether all colors return grayscale values.
1363  return fgGrayscaleMode;
1364 }
1365 
1366 ////////////////////////////////////////////////////////////////////////////////
1367 /// Set whether all colors should return grayscale values.
1368 
1369 void TColor::SetGrayscale(Bool_t set /*= kTRUE*/)
1371  if (fgGrayscaleMode == set) return;
1372 
1373  fgGrayscaleMode = set;
1374 
1375  if (!gVirtualX || gROOT->IsBatch()) return;
1376 
1378  TIter iColor(gROOT->GetListOfColors());
1379  TColor* color = 0;
1380  while ((color = (TColor*) iColor()))
1381  color->Allocate();
1382 }
1383 
1384 ////////////////////////////////////////////////////////////////////////////////
1385 /// Static function creating a color table with several connected linear gradients.
1386 ///
1387 /// - Number: The number of end point colors that will form the gradients.
1388 /// Must be at least 2.
1389 /// - Stops: Where in the whole table the end point colors should lie.
1390 /// Each entry must be on [0, 1], each entry must be greater than
1391 /// the previous entry.
1392 /// - Red, Green, Blue: The end point color values.
1393 /// Each entry must be on [0, 1]
1394 /// - NColors: Total number of colors in the table. Must be at least 1.
1395 ///
1396 /// Returns a positive value on success and -1 on error.
1397 ///
1398 /// The table is constructed by tracing lines between the given points in
1399 /// RGB space. Each color value may have a value between 0 and 1. The
1400 /// difference between consecutive "Stops" values gives the fraction of
1401 /// space in the whole table that should be used for the interval between
1402 /// the corresponding color values.
1403 ///
1404 /// Normally the first element of Stops should be 0 and the last should be 1.
1405 /// If this is not true, fewer than NColors will be used in proportion with
1406 /// the total interval between the first and last elements of Stops.
1407 ///
1408 /// This definition is similar to the povray-definition of gradient
1409 /// color tables.
1410 ///
1411 /// For instance:
1412 /// ~~~ {.cpp}
1413 /// UInt_t Number = 3;
1414 /// Double_t Red[3] = { 0.0, 1.0, 1.0 };
1415 /// Double_t Green[3] = { 0.0, 0.0, 1.0 };
1416 /// Double_t Blue[3] = { 1.0, 0.0, 1.0 };
1417 /// Double_t Stops[3] = { 0.0, 0.4, 1.0 };
1418 /// ~~~
1419 /// This defines a table in which there are three color end points:
1420 /// RGB = {0, 0, 1}, {1, 0, 0}, and {1, 1, 1} = blue, red, white
1421 /// The first 40% of the table is used to go linearly from blue to red.
1422 /// The remaining 60% of the table is used to go linearly from red to white.
1423 ///
1424 /// If you define a very short interval such that less than one color fits
1425 /// in it, no colors at all will be allocated. If this occurs for all
1426 /// intervals, ROOT will revert to the default palette.
1427 ///
1428 /// Original code by Andreas Zoglauer (zog@mpe.mpg.de)
1429 
1431  Double_t* Red, Double_t* Green,
1432  Double_t* Blue, UInt_t NColors, Float_t alpha)
1433 {
1435 
1436  UInt_t g, c;
1437  UInt_t nPalette = 0;
1438  Int_t *palette = new Int_t[NColors+1];
1439  UInt_t nColorsGradient;
1440  TColor *color;
1441  Int_t highestIndex = 0;
1442 
1443  if(Number < 2 || NColors < 1){
1444  delete [] palette;
1445  return -1;
1446  }
1447 
1448  // Check if all RGB values are between 0.0 and 1.0 and
1449  // Stops goes from 0.0 to 1.0 in increasing order.
1450  for (c = 0; c < Number; c++) {
1451  if (Red[c] < 0 || Red[c] > 1.0 ||
1452  Green[c] < 0 || Green[c] > 1.0 ||
1453  Blue[c] < 0 || Blue[c] > 1.0 ||
1454  Stops[c] < 0 || Stops[c] > 1.0) {
1455  delete [] palette;
1456  return -1;
1457  }
1458  if (c >= 1) {
1459  if (Stops[c-1] > Stops[c]) {
1460  delete [] palette;
1461  return -1;
1462  }
1463  }
1464  }
1465 
1466  // Search for the highest color index not used in ROOT:
1467  // We do not want to overwrite some colors...
1468  TSeqCollection *colorTable = gROOT->GetListOfColors();
1469  if ((color = (TColor *) colorTable->Last()) != 0) {
1470  if (color->GetNumber() > highestIndex) {
1471  highestIndex = color->GetNumber();
1472  }
1473  while ((color = (TColor *) (colorTable->Before(color))) != 0) {
1474  if (color->GetNumber() > highestIndex) {
1475  highestIndex = color->GetNumber();
1476  }
1477  }
1478  }
1479  highestIndex++;
1480 
1481  // Now create the colors and add them to the default palette:
1482 
1483  // For each defined gradient...
1484  TColor *hi;
1485  for (g = 1; g < Number; g++) {
1486  // create the colors...
1487  nColorsGradient = (Int_t) (floor(NColors*Stops[g]) - floor(NColors*Stops[g-1]));
1488  for (c = 0; c < nColorsGradient; c++) {
1489  new TColor(highestIndex,
1490  Red[g-1] + c * (Red[g] - Red[g-1])/ nColorsGradient,
1491  Green[g-1] + c * (Green[g] - Green[g-1])/ nColorsGradient,
1492  Blue[g-1] + c * (Blue[g] - Blue[g-1])/ nColorsGradient,
1493  " ");
1494  hi = gROOT->GetColor(highestIndex);
1495  if (hi) hi->SetAlpha(alpha);
1496  palette[nPalette] = highestIndex;
1497  nPalette++;
1498  highestIndex++;
1499  }
1500  }
1501 
1502  TColor::SetPalette(nPalette, palette);
1503  delete [] palette;
1504 
1505  return highestIndex - NColors;
1506 }
1507 
1508 
1509 ////////////////////////////////////////////////////////////////////////////////
1510 /// Static function.
1511 /// The color palette is used by the histogram classes
1512 /// (see TH1::Draw options).
1513 /// For example TH1::Draw("col") draws a 2-D histogram with cells
1514 /// represented by a box filled with a color CI function of the cell content.
1515 /// if the cell content is N, the color CI used will be the color number
1516 /// in colors[N],etc. If the maximum cell content is > ncolors, all
1517 /// cell contents are scaled to ncolors.
1518 ///
1519 /// `if ncolors <= 0` a default palette (see below) of 50 colors is
1520 /// defined. The colors defined in this palette are OK for coloring pads, labels.
1521 ///
1522 /// ~~~ {.cpp}
1523 /// index 0->9 : grey colors from light to dark grey
1524 /// index 10->19 : "brown" colors
1525 /// index 20->29 : "blueish" colors
1526 /// index 30->39 : "redish" colors
1527 /// index 40->49 : basic colors
1528 /// ~~~
1529 ///
1530 /// `if ncolors == 1 && colors == 0`, a Rainbow Color map is created
1531 /// with 50 colors. It is kept for backward compatibility. Better palettes like
1532 /// kBird are recommended.
1533 ///
1534 /// High quality predefined palettes with 255 colors are available when `colors == 0`.
1535 /// The following value of `ncolors` give access to:
1536 ///
1537 /// ~~~ {.cpp}
1538 /// if ncolors = 51 and colors=0, a Deep Sea palette is used.
1539 /// if ncolors = 52 and colors=0, a Grey Scale palette is used.
1540 /// if ncolors = 53 and colors=0, a Dark Body Radiator palette is used.
1541 /// if ncolors = 54 and colors=0, a Two-Color Hue palette is used.(dark blue through neutral gray to bright yellow)
1542 /// if ncolors = 55 and colors=0, a Rain Bow palette is used.
1543 /// if ncolors = 56 and colors=0, an Inverted Dark Body Radiator palette is used.
1544 /// if ncolors = 57 and colors=0, a monotonically increasing L value palette is used.
1545 /// if ncolors = 58 and colors=0, a Cubehelix palette is used
1546 /// (Cf. Dave Green's "cubehelix" colour scheme at http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/)
1547 /// if ncolors = 59 and colors=0, a Green Red Violet palette is used.
1548 /// if ncolors = 60 and colors=0, a Blue Red Yellow palette is used.
1549 /// if ncolors = 61 and colors=0, an Ocean palette is used.
1550 /// if ncolors = 62 and colors=0, a Color Printable On Grey palette is used.
1551 /// if ncolors = 63 and colors=0, an Alpine palette is used.
1552 /// if ncolors = 64 and colors=0, an Aquamarine palette is used.
1553 /// if ncolors = 65 and colors=0, an Army palette is used.
1554 /// if ncolors = 66 and colors=0, an Atlantic palette is used.
1555 /// if ncolors = 67 and colors=0, an Aurora palette is used.
1556 /// if ncolors = 68 and colors=0, an Avocado palette is used.
1557 /// if ncolors = 69 and colors=0, a Beach palette is used.
1558 /// if ncolors = 70 and colors=0, a Black Body palette is used.
1559 /// if ncolors = 71 and colors=0, a Blue Green Yellow palette is used.
1560 /// if ncolors = 72 and colors=0, a Brown Cyan palette is used.
1561 /// if ncolors = 73 and colors=0, a CMYK palette is used.
1562 /// if ncolors = 74 and colors=0, a Candy palette is used.
1563 /// if ncolors = 75 and colors=0, a Cherry palette is used.
1564 /// if ncolors = 76 and colors=0, a Coffee palette is used.
1565 /// if ncolors = 77 and colors=0, a Dark Rain Bow palette is used.
1566 /// if ncolors = 78 and colors=0, a Dark Terrain palette is used.
1567 /// if ncolors = 79 and colors=0, a Fall palette is used.
1568 /// if ncolors = 80 and colors=0, a Fruit Punch palette is used.
1569 /// if ncolors = 81 and colors=0, a Fuchsia palette is used.
1570 /// if ncolors = 82 and colors=0, a Grey Yellow palette is used.
1571 /// if ncolors = 83 and colors=0, a Green Brown Terrain palette is used.
1572 /// if ncolors = 84 and colors=0, a Green Pink palette is used.
1573 /// if ncolors = 85 and colors=0, an Island palette is used.
1574 /// if ncolors = 86 and colors=0, a Lake palette is used.
1575 /// if ncolors = 87 and colors=0, a Light Temperature palette is used.
1576 /// if ncolors = 88 and colors=0, a Light Terrain palette is used.
1577 /// if ncolors = 89 and colors=0, a Mint palette is used.
1578 /// if ncolors = 90 and colors=0, a Neon palette is used.
1579 /// if ncolors = 91 and colors=0, a Pastel palette is used.
1580 /// if ncolors = 92 and colors=0, a Pearl palette is used.
1581 /// if ncolors = 93 and colors=0, a Pigeon palette is used.
1582 /// if ncolors = 94 and colors=0, a Plum palette is used.
1583 /// if ncolors = 95 and colors=0, a Red Blue palette is used.
1584 /// if ncolors = 96 and colors=0, a Rose palette is used.
1585 /// if ncolors = 97 and colors=0, a Rust palette is used.
1586 /// if ncolors = 98 and colors=0, a Sandy Terrain palette is used.
1587 /// if ncolors = 99 and colors=0, a Sienna palette is used.
1588 /// if ncolors = 100 and colors=0, a Solar palette is used.
1589 /// if ncolors = 101 and colors=0, a South West palette is used.
1590 /// if ncolors = 102 and colors=0, a Starry Night palette is used.
1591 /// if ncolors = 103 and colors=0, a Sunset palette is used.
1592 /// if ncolors = 104 and colors=0, a Temperature Map palette is used.
1593 /// if ncolors = 105 and colors=0, a Thermometer palette is used.
1594 /// if ncolors = 106 and colors=0, a Valentine palette is used.
1595 /// if ncolors = 107 and colors=0, a Visible Spectrum palette is used.
1596 /// if ncolors = 108 and colors=0, a Water Melon palette is used.
1597 /// if ncolors = 109 and colors=0, a Cool palette is used.
1598 /// if ncolors = 110 and colors=0, a Copper palette is used.
1599 /// if ncolors = 111 and colors=0, a Gist Earth palette is used.
1600 /// if ncolors = 112 and colors=0, a Viridis palette is used.
1601 /// ~~~
1602 /// These palettes can also be accessed by names:
1603 /// ~~~ {.cpp}
1604 /// kDeepSea=51, kGreyScale=52, kDarkBodyRadiator=53,
1605 /// kBlueYellow= 54, kRainBow=55, kInvertedDarkBodyRadiator=56,
1606 /// kBird=57, kCubehelix=58, kGreenRedViolet=59,
1607 /// kBlueRedYellow=60, kOcean=61, kColorPrintableOnGrey=62,
1608 /// kAlpine=63, kAquamarine=64, kArmy=65,
1609 /// kAtlantic=66, kAurora=67, kAvocado=68,
1610 /// kBeach=69, kBlackBody=70, kBlueGreenYellow=71,
1611 /// kBrownCyan=72, kCMYK=73, kCandy=74,
1612 /// kCherry=75, kCoffee=76, kDarkRainBow=77,
1613 /// kDarkTerrain=78, kFall=79, kFruitPunch=80,
1614 /// kFuchsia=81, kGreyYellow=82, kGreenBrownTerrain=83,
1615 /// kGreenPink=84, kIsland=85, kLake=86,
1616 /// kLightTemperature=87, kLightTerrain=88, kMint=89,
1617 /// kNeon=90, kPastel=91, kPearl=92,
1618 /// kPigeon=93, kPlum=94, kRedBlue=95,
1619 /// kRose=96, kRust=97, kSandyTerrain=98,
1620 /// kSienna=99, kSolar=100, kSouthWest=101,
1621 /// kStarryNight=102, kSunset=103, kTemperatureMap=104,
1622 /// kThermometer=105, kValentine=106, kVisibleSpectrum=107,
1623 /// kWaterMelon=108, kCool=109, kCopper=110,
1624 /// kGistEarth=111 kViridis=112
1625 /// ~~~
1626 /// For example:
1627 /// ~~~ {.cpp}
1628 /// gStyle->SetPalette(kBird);
1629 /// ~~~
1630 /// Set the current palette as "Bird" (number 57).
1631 ///
1632 /// The color numbers specified in the palette can be viewed by selecting
1633 /// the item "colors" in the "VIEW" menu of the canvas toolbar.
1634 /// The color parameters can be changed via TColor::SetRGB.
1635 ///
1636 /// Note that when drawing a 2D histogram `h2` with the option "COL" or
1637 /// "COLZ" or with any "CONT" options using the color map, the number of colors
1638 /// used is defined by the number of contours `n` specified with:
1639 /// `h2->SetContour(n)`
1640 
1641 void TColor::SetPalette(Int_t ncolors, Int_t *colors, Float_t alpha)
1643  Int_t i;
1644  static Int_t paletteType = 0;
1645  Int_t palette[50] = {19,18,17,16,15,14,13,12,11,20,
1646  21,22,23,24,25,26,27,28,29,30, 8,
1647  31,32,33,34,35,36,37,38,39,40, 9,
1648  41,42,43,44,45,47,48,49,46,50, 2,
1649  7, 6, 5, 4, 3, 2,1};
1650  // set default palette (pad type)
1651  if (ncolors <= 0) {
1652  ncolors = 50;
1653  fgPalette.Set(ncolors);
1654  for (i=0;i<ncolors;i++) fgPalette.fArray[i] = palette[i];
1655  paletteType = 1;
1656  return;
1657  }
1658 
1659  // set Rainbow Color map. Kept for backward compatibility.
1660  if (ncolors == 1 && colors == 0) {
1661  ncolors = 50;
1662  fgPalette.Set(ncolors);
1663  for (i=0;i<ncolors;i++) fgPalette.fArray[i] = 51+i;
1664  paletteType = 2;
1665  return;
1666  }
1667 
1668  // High quality palettes (255 levels)
1669  if (colors == 0 && ncolors>50) {
1670  if (paletteType == ncolors) return;
1671 
1673  Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
1674 
1675  switch (ncolors) {
1676 
1677  // Deep Sea
1678  case 51:
1679  {
1680  Double_t red[9] = { 0./255., 9./255., 13./255., 17./255., 24./255., 32./255., 27./255., 25./255., 29./255.};
1681  Double_t green[9] = { 0./255., 0./255., 0./255., 2./255., 37./255., 74./255., 113./255., 160./255., 221./255.};
1682  Double_t blue[9] = { 28./255., 42./255., 59./255., 78./255., 98./255., 129./255., 154./255., 184./255., 221./255.};
1683  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1684  }
1685  break;
1686 
1687  // Grey Scale
1688  case 52:
1689  {
1690  Double_t red[9] = { 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.};
1691  Double_t green[9] = { 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.};
1692  Double_t blue[9] = { 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.};
1693  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1694  }
1695  break;
1696 
1697  // Dark Body Radiator
1698  case 53:
1699  {
1700  Double_t red[9] = { 0./255., 45./255., 99./255., 156./255., 212./255., 230./255., 237./255., 234./255., 242./255.};
1701  Double_t green[9] = { 0./255., 0./255., 0./255., 45./255., 101./255., 168./255., 238./255., 238./255., 243./255.};
1702  Double_t blue[9] = { 0./255., 1./255., 1./255., 3./255., 9./255., 8./255., 11./255., 95./255., 230./255.};
1703  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1704  }
1705  break;
1706 
1707  // Two-color hue (dark blue through neutral gray to bright yellow)
1708  case 54:
1709  {
1710  Double_t red[9] = { 0./255., 22./255., 44./255., 68./255., 93./255., 124./255., 160./255., 192./255., 237./255.};
1711  Double_t green[9] = { 0./255., 16./255., 41./255., 67./255., 93./255., 125./255., 162./255., 194./255., 241./255.};
1712  Double_t blue[9] = { 97./255., 100./255., 99./255., 99./255., 93./255., 68./255., 44./255., 26./255., 74./255.};
1713  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1714  }
1715  break;
1716 
1717  // Rain Bow
1718  case 55:
1719  {
1720  Double_t red[9] = { 0./255., 5./255., 15./255., 35./255., 102./255., 196./255., 208./255., 199./255., 110./255.};
1721  Double_t green[9] = { 0./255., 48./255., 124./255., 192./255., 206./255., 226./255., 97./255., 16./255., 0./255.};
1722  Double_t blue[9] = { 99./255., 142./255., 198./255., 201./255., 90./255., 22./255., 13./255., 8./255., 2./255.};
1723  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1724  }
1725  break;
1726 
1727  // Inverted Dark Body Radiator
1728  case 56:
1729  {
1730  Double_t red[9] = { 242./255., 234./255., 237./255., 230./255., 212./255., 156./255., 99./255., 45./255., 0./255.};
1731  Double_t green[9] = { 243./255., 238./255., 238./255., 168./255., 101./255., 45./255., 0./255., 0./255., 0./255.};
1732  Double_t blue[9] = { 230./255., 95./255., 11./255., 8./255., 9./255., 3./255., 1./255., 1./255., 0./255.};
1733  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1734  }
1735  break;
1736 
1737  // Bird
1738  case 57:
1739  {
1740  Double_t red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764};
1741  Double_t green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832};
1742  Double_t blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539};
1743  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1744  }
1745  break;
1746 
1747  // Cubehelix
1748  case 58:
1749  {
1750  Double_t red[9] = { 0.0000, 0.0956, 0.0098, 0.2124, 0.6905, 0.9242, 0.7914, 0.7596, 1.0000};
1751  Double_t green[9] = { 0.0000, 0.1147, 0.3616, 0.5041, 0.4577, 0.4691, 0.6905, 0.9237, 1.0000};
1752  Double_t blue[9] = { 0.0000, 0.2669, 0.3121, 0.1318, 0.2236, 0.6741, 0.9882, 0.9593, 1.0000};
1753  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1754  }
1755  break;
1756 
1757  // Green Red Violet
1758  case 59:
1759  {
1760  Double_t red[9] = {13./255., 23./255., 25./255., 63./255., 76./255., 104./255., 137./255., 161./255., 206./255.};
1761  Double_t green[9] = {95./255., 67./255., 37./255., 21./255., 0./255., 12./255., 35./255., 52./255., 79./255.};
1762  Double_t blue[9] = { 4./255., 3./255., 2./255., 6./255., 11./255., 22./255., 49./255., 98./255., 208./255.};
1763  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1764  }
1765  break;
1766 
1767  // Blue Red Yellow
1768  case 60:
1769  {
1770  Double_t red[9] = {0./255., 61./255., 89./255., 122./255., 143./255., 160./255., 185./255., 204./255., 231./255.};
1771  Double_t green[9] = {0./255., 0./255., 0./255., 0./255., 14./255., 37./255., 72./255., 132./255., 235./255.};
1772  Double_t blue[9] = {0./255., 140./255., 224./255., 144./255., 4./255., 5./255., 6./255., 9./255., 13./255.};
1773  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1774  }
1775  break;
1776 
1777  // Ocean
1778  case 61:
1779  {
1780  Double_t red[9] = { 14./255., 7./255., 2./255., 0./255., 5./255., 11./255., 55./255., 131./255., 229./255.};
1781  Double_t green[9] = {105./255., 56./255., 26./255., 1./255., 42./255., 74./255., 131./255., 171./255., 229./255.};
1782  Double_t blue[9] = { 2./255., 21./255., 35./255., 60./255., 92./255., 113./255., 160./255., 185./255., 229./255.};
1783  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1784  }
1785  break;
1786 
1787  // Color Printable On Grey
1788  case 62:
1789  {
1790  Double_t red[9] = { 0./255., 0./255., 0./255., 70./255., 148./255., 231./255., 235./255., 237./255., 244./255.};
1791  Double_t green[9] = { 0./255., 0./255., 0./255., 0./255., 0./255., 69./255., 67./255., 216./255., 244./255.};
1792  Double_t blue[9] = { 0./255., 102./255., 228./255., 231./255., 177./255., 124./255., 137./255., 20./255., 244./255.};
1793  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1794  }
1795  break;
1796 
1797  // Alpine
1798  case 63:
1799  {
1800  Double_t red[9] = { 50./255., 56./255., 63./255., 68./255., 93./255., 121./255., 165./255., 192./255., 241./255.};
1801  Double_t green[9] = { 66./255., 81./255., 91./255., 96./255., 111./255., 128./255., 155./255., 189./255., 241./255.};
1802  Double_t blue[9] = { 97./255., 91./255., 75./255., 65./255., 77./255., 103./255., 143./255., 167./255., 217./255.};
1803  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1804  }
1805  break;
1806 
1807  // Aquamarine
1808  case 64:
1809  {
1810  Double_t red[9] = { 145./255., 166./255., 167./255., 156./255., 131./255., 114./255., 101./255., 112./255., 132./255.};
1811  Double_t green[9] = { 158./255., 178./255., 179./255., 181./255., 163./255., 154./255., 144./255., 152./255., 159./255.};
1812  Double_t blue[9] = { 190./255., 199./255., 201./255., 192./255., 176./255., 169./255., 160./255., 166./255., 190./255.};
1813  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1814  }
1815  break;
1816 
1817  // Army
1818  case 65:
1819  {
1820  Double_t red[9] = { 93./255., 91./255., 99./255., 108./255., 130./255., 125./255., 132./255., 155./255., 174./255.};
1821  Double_t green[9] = { 126./255., 124./255., 128./255., 129./255., 131./255., 121./255., 119./255., 153./255., 173./255.};
1822  Double_t blue[9] = { 103./255., 94./255., 87./255., 85./255., 80./255., 85./255., 107./255., 120./255., 146./255.};
1823  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1824  }
1825  break;
1826 
1827  // Atlantic
1828  case 66:
1829  {
1830  Double_t red[9] = { 24./255., 40./255., 69./255., 90./255., 104./255., 114./255., 120./255., 132./255., 103./255.};
1831  Double_t green[9] = { 29./255., 52./255., 94./255., 127./255., 150./255., 162./255., 159./255., 151./255., 101./255.};
1832  Double_t blue[9] = { 29./255., 52./255., 96./255., 132./255., 162./255., 181./255., 184./255., 186./255., 131./255.};
1833  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1834  }
1835  break;
1836 
1837  // Aurora
1838  case 67:
1839  {
1840  Double_t red[9] = { 46./255., 38./255., 61./255., 92./255., 113./255., 121./255., 132./255., 150./255., 191./255.};
1841  Double_t green[9] = { 46./255., 36./255., 40./255., 69./255., 110./255., 135./255., 131./255., 92./255., 34./255.};
1842  Double_t blue[9] = { 46./255., 80./255., 74./255., 70./255., 81./255., 105./255., 165./255., 211./255., 225./255.};
1843  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1844  }
1845  break;
1846 
1847  // Avocado
1848  case 68:
1849  {
1850  Double_t red[9] = { 0./255., 4./255., 12./255., 30./255., 52./255., 101./255., 142./255., 190./255., 237./255.};
1851  Double_t green[9] = { 0./255., 40./255., 86./255., 121./255., 140./255., 172./255., 187./255., 213./255., 240./255.};
1852  Double_t blue[9] = { 0./255., 9./255., 14./255., 18./255., 21./255., 23./255., 27./255., 35./255., 101./255.};
1853  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1854  }
1855  break;
1856 
1857  // Beach
1858  case 69:
1859  {
1860  Double_t red[9] = { 198./255., 206./255., 206./255., 211./255., 198./255., 181./255., 161./255., 171./255., 244./255.};
1861  Double_t green[9] = { 103./255., 133./255., 150./255., 172./255., 178./255., 174./255., 163./255., 175./255., 244./255.};
1862  Double_t blue[9] = { 49./255., 54./255., 55./255., 66./255., 91./255., 130./255., 184./255., 224./255., 244./255.};
1863  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1864  }
1865  break;
1866 
1867  // Black Body
1868  case 70:
1869  {
1870  Double_t red[9] = { 243./255., 243./255., 240./255., 240./255., 241./255., 239./255., 186./255., 151./255., 129./255.};
1871  Double_t green[9] = { 0./255., 46./255., 99./255., 149./255., 194./255., 220./255., 183./255., 166./255., 147./255.};
1872  Double_t blue[9] = { 6./255., 8./255., 36./255., 91./255., 169./255., 235./255., 246./255., 240./255., 233./255.};
1873  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1874  }
1875  break;
1876 
1877  // Blue Green Yellow
1878  case 71:
1879  {
1880  Double_t red[9] = { 22./255., 19./255., 19./255., 25./255., 35./255., 53./255., 88./255., 139./255., 210./255.};
1881  Double_t green[9] = { 0./255., 32./255., 69./255., 108./255., 135./255., 159./255., 183./255., 198./255., 215./255.};
1882  Double_t blue[9] = { 77./255., 96./255., 110./255., 116./255., 110./255., 100./255., 90./255., 78./255., 70./255.};
1883  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1884  }
1885  break;
1886 
1887  // Brown Cyan
1888  case 72:
1889  {
1890  Double_t red[9] = { 68./255., 116./255., 165./255., 182./255., 189./255., 180./255., 145./255., 111./255., 71./255.};
1891  Double_t green[9] = { 37./255., 82./255., 135./255., 178./255., 204./255., 225./255., 221./255., 202./255., 147./255.};
1892  Double_t blue[9] = { 16./255., 55./255., 105./255., 147./255., 196./255., 226./255., 232./255., 224./255., 178./255.};
1893  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1894  }
1895  break;
1896 
1897  // CMYK
1898  case 73:
1899  {
1900  Double_t red[9] = { 61./255., 99./255., 136./255., 181./255., 213./255., 225./255., 198./255., 136./255., 24./255.};
1901  Double_t green[9] = { 149./255., 140./255., 96./255., 83./255., 132./255., 178./255., 190./255., 135./255., 22./255.};
1902  Double_t blue[9] = { 214./255., 203./255., 168./255., 135./255., 110./255., 100./255., 111./255., 113./255., 22./255.};
1903  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1904  }
1905  break;
1906 
1907  // Candy
1908  case 74:
1909  {
1910  Double_t red[9] = { 76./255., 120./255., 156./255., 183./255., 197./255., 180./255., 162./255., 154./255., 140./255.};
1911  Double_t green[9] = { 34./255., 35./255., 42./255., 69./255., 102./255., 137./255., 164./255., 188./255., 197./255.};
1912  Double_t blue[9] = { 64./255., 69./255., 78./255., 105./255., 142./255., 177./255., 205./255., 217./255., 198./255.};
1913  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1914  }
1915  break;
1916 
1917  // Cherry
1918  case 75:
1919  {
1920  Double_t red[9] = { 37./255., 102./255., 157./255., 188./255., 196./255., 214./255., 223./255., 235./255., 251./255.};
1921  Double_t green[9] = { 37./255., 29./255., 25./255., 37./255., 67./255., 91./255., 132./255., 185./255., 251./255.};
1922  Double_t blue[9] = { 37./255., 32./255., 33./255., 45./255., 66./255., 98./255., 137./255., 187./255., 251./255.};
1923  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1924  }
1925  break;
1926 
1927  // Coffee
1928  case 76:
1929  {
1930  Double_t red[9] = { 79./255., 100./255., 119./255., 137./255., 153./255., 172./255., 192./255., 205./255., 250./255.};
1931  Double_t green[9] = { 63./255., 79./255., 93./255., 103./255., 115./255., 135./255., 167./255., 196./255., 250./255.};
1932  Double_t blue[9] = { 51./255., 59./255., 66./255., 61./255., 62./255., 70./255., 110./255., 160./255., 250./255.};
1933  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1934  }
1935  break;
1936 
1937  // Dark Rain Bow
1938  case 77:
1939  {
1940  Double_t red[9] = { 43./255., 44./255., 50./255., 66./255., 125./255., 172./255., 178./255., 155./255., 157./255.};
1941  Double_t green[9] = { 63./255., 63./255., 85./255., 101./255., 138./255., 163./255., 122./255., 51./255., 39./255.};
1942  Double_t blue[9] = { 121./255., 101./255., 58./255., 44./255., 47./255., 55./255., 57./255., 44./255., 43./255.};
1943  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1944  }
1945  break;
1946 
1947  // Dark Terrain
1948  case 78:
1949  {
1950  Double_t red[9] = { 0./255., 41./255., 62./255., 79./255., 90./255., 87./255., 99./255., 140./255., 228./255.};
1951  Double_t green[9] = { 0./255., 57./255., 81./255., 93./255., 85./255., 70./255., 71./255., 125./255., 228./255.};
1952  Double_t blue[9] = { 95./255., 91./255., 91./255., 82./255., 60./255., 43./255., 44./255., 112./255., 228./255.};
1953  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1954  }
1955  break;
1956 
1957  // Fall
1958  case 79:
1959  {
1960  Double_t red[9] = { 49./255., 59./255., 72./255., 88./255., 114./255., 141./255., 176./255., 205./255., 222./255.};
1961  Double_t green[9] = { 78./255., 72./255., 66./255., 57./255., 59./255., 75./255., 106./255., 142./255., 173./255.};
1962  Double_t blue[9] = { 78./255., 55./255., 46./255., 40./255., 39./255., 39./255., 40./255., 41./255., 47./255.};
1963  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1964  }
1965  break;
1966 
1967  // Fruit Punch
1968  case 80:
1969  {
1970  Double_t red[9] = { 243./255., 222./255., 201./255., 185./255., 165./255., 158./255., 166./255., 187./255., 219./255.};
1971  Double_t green[9] = { 94./255., 108./255., 132./255., 135./255., 125./255., 96./255., 68./255., 51./255., 61./255.};
1972  Double_t blue[9] = { 7./255., 9./255., 12./255., 19./255., 45./255., 89./255., 118./255., 146./255., 118./255.};
1973  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1974  }
1975  break;
1976 
1977  // Fuchsia
1978  case 81:
1979  {
1980  Double_t red[9] = { 19./255., 44./255., 74./255., 105./255., 137./255., 166./255., 194./255., 206./255., 220./255.};
1981  Double_t green[9] = { 19./255., 28./255., 40./255., 55./255., 82./255., 110./255., 159./255., 181./255., 220./255.};
1982  Double_t blue[9] = { 19./255., 42./255., 68./255., 96./255., 129./255., 157./255., 188./255., 203./255., 220./255.};
1983  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1984  }
1985  break;
1986 
1987  // Grey Yellow
1988  case 82:
1989  {
1990  Double_t red[9] = { 33./255., 44./255., 70./255., 99./255., 140./255., 165./255., 199./255., 211./255., 216./255.};
1991  Double_t green[9] = { 38./255., 50./255., 76./255., 105./255., 140./255., 165./255., 191./255., 189./255., 167./255.};
1992  Double_t blue[9] = { 55./255., 67./255., 97./255., 124./255., 140./255., 166./255., 163./255., 129./255., 52./255.};
1993  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
1994  }
1995  break;
1996 
1997  // Green Brown Terrain
1998  case 83:
1999  {
2000  Double_t red[9] = { 0./255., 33./255., 73./255., 124./255., 136./255., 152./255., 159./255., 171./255., 223./255.};
2001  Double_t green[9] = { 0./255., 43./255., 92./255., 124./255., 134./255., 126./255., 121./255., 144./255., 223./255.};
2002  Double_t blue[9] = { 0./255., 43./255., 68./255., 76./255., 73./255., 64./255., 72./255., 114./255., 223./255.};
2003  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2004  }
2005  break;
2006 
2007  // Green Pink
2008  case 84:
2009  {
2010  Double_t red[9] = { 5./255., 18./255., 45./255., 124./255., 193./255., 223./255., 205./255., 128./255., 49./255.};
2011  Double_t green[9] = { 48./255., 134./255., 207./255., 230./255., 193./255., 113./255., 28./255., 0./255., 7./255.};
2012  Double_t blue[9] = { 6./255., 15./255., 41./255., 121./255., 193./255., 226./255., 208./255., 130./255., 49./255.};
2013  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2014  }
2015  break;
2016 
2017  // Island
2018  case 85:
2019  {
2020  Double_t red[9] = { 180./255., 106./255., 104./255., 135./255., 164./255., 188./255., 189./255., 165./255., 144./255.};
2021  Double_t green[9] = { 72./255., 126./255., 154./255., 184./255., 198./255., 207./255., 205./255., 190./255., 179./255.};
2022  Double_t blue[9] = { 41./255., 120./255., 158./255., 188./255., 194./255., 181./255., 145./255., 100./255., 62./255.};
2023  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2024  }
2025  break;
2026 
2027  // Lake
2028  case 86:
2029  {
2030  Double_t red[9] = { 57./255., 72./255., 94./255., 117./255., 136./255., 154./255., 174./255., 192./255., 215./255.};
2031  Double_t green[9] = { 0./255., 33./255., 68./255., 109./255., 140./255., 171./255., 192./255., 196./255., 209./255.};
2032  Double_t blue[9] = { 116./255., 137./255., 173./255., 201./255., 200./255., 201./255., 203./255., 190./255., 187./255.};
2033  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2034  }
2035  break;
2036 
2037  // Light Temperature
2038  case 87:
2039  {
2040  Double_t red[9] = { 31./255., 71./255., 123./255., 160./255., 210./255., 222./255., 214./255., 199./255., 183./255.};
2041  Double_t green[9] = { 40./255., 117./255., 171./255., 211./255., 231./255., 220./255., 190./255., 132./255., 65./255.};
2042  Double_t blue[9] = { 234./255., 214./255., 228./255., 222./255., 210./255., 160./255., 105./255., 60./255., 34./255.};
2043  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2044  }
2045  break;
2046 
2047  // Light Terrain
2048  case 88:
2049  {
2050  Double_t red[9] = { 123./255., 108./255., 109./255., 126./255., 154./255., 172./255., 188./255., 196./255., 218./255.};
2051  Double_t green[9] = { 184./255., 138./255., 130./255., 133./255., 154./255., 175./255., 188./255., 196./255., 218./255.};
2052  Double_t blue[9] = { 208./255., 130./255., 109./255., 99./255., 110./255., 122./255., 150./255., 171./255., 218./255.};
2053  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2054  }
2055  break;
2056 
2057  // Mint
2058  case 89:
2059  {
2060  Double_t red[9] = { 105./255., 106./255., 122./255., 143./255., 159./255., 172./255., 176./255., 181./255., 207./255.};
2061  Double_t green[9] = { 252./255., 197./255., 194./255., 187./255., 174./255., 162./255., 153./255., 136./255., 125./255.};
2062  Double_t blue[9] = { 146./255., 133./255., 144./255., 155./255., 163./255., 167./255., 166./255., 162./255., 174./255.};
2063  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2064  }
2065  break;
2066 
2067  // Neon
2068  case 90:
2069  {
2070  Double_t red[9] = { 171./255., 141./255., 145./255., 152./255., 154./255., 159./255., 163./255., 158./255., 177./255.};
2071  Double_t green[9] = { 236./255., 143./255., 100./255., 63./255., 53./255., 55./255., 44./255., 31./255., 6./255.};
2072  Double_t blue[9] = { 59./255., 48./255., 46./255., 44./255., 42./255., 54./255., 82./255., 112./255., 179./255.};
2073  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2074  }
2075  break;
2076 
2077  // Pastel
2078  case 91:
2079  {
2080  Double_t red[9] = { 180./255., 190./255., 209./255., 223./255., 204./255., 228./255., 205./255., 152./255., 91./255.};
2081  Double_t green[9] = { 93./255., 125./255., 147./255., 172./255., 181./255., 224./255., 233./255., 198./255., 158./255.};
2082  Double_t blue[9] = { 236./255., 218./255., 160./255., 133./255., 114./255., 132./255., 162./255., 220./255., 218./255.};
2083  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2084  }
2085  break;
2086 
2087  // Pearl
2088  case 92:
2089  {
2090  Double_t red[9] = { 225./255., 183./255., 162./255., 135./255., 115./255., 111./255., 119./255., 145./255., 211./255.};
2091  Double_t green[9] = { 205./255., 177./255., 166./255., 135./255., 124./255., 117./255., 117./255., 132./255., 172./255.};
2092  Double_t blue[9] = { 186./255., 165./255., 155./255., 135./255., 126./255., 130./255., 150./255., 178./255., 226./255.};
2093  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2094  }
2095  break;
2096 
2097  // Pigeon
2098  case 93:
2099  {
2100  Double_t red[9] = { 39./255., 43./255., 59./255., 63./255., 80./255., 116./255., 153./255., 177./255., 223./255.};
2101  Double_t green[9] = { 39./255., 43./255., 59./255., 74./255., 91./255., 114./255., 139./255., 165./255., 223./255.};
2102  Double_t blue[9] = { 39./255., 50./255., 59./255., 70./255., 85./255., 115./255., 151./255., 176./255., 223./255.};
2103  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2104  }
2105  break;
2106 
2107  // Plum
2108  case 94:
2109  {
2110  Double_t red[9] = { 0./255., 38./255., 60./255., 76./255., 84./255., 89./255., 101./255., 128./255., 204./255.};
2111  Double_t green[9] = { 0./255., 10./255., 15./255., 23./255., 35./255., 57./255., 83./255., 123./255., 199./255.};
2112  Double_t blue[9] = { 0./255., 11./255., 22./255., 40./255., 63./255., 86./255., 97./255., 94./255., 85./255.};
2113  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2114  }
2115  break;
2116 
2117  // Red Blue
2118  case 95:
2119  {
2120  Double_t red[9] = { 94./255., 112./255., 141./255., 165./255., 167./255., 140./255., 91./255., 49./255., 27./255.};
2121  Double_t green[9] = { 27./255., 46./255., 88./255., 135./255., 166./255., 161./255., 135./255., 97./255., 58./255.};
2122  Double_t blue[9] = { 42./255., 52./255., 81./255., 106./255., 139./255., 158./255., 155./255., 137./255., 116./255.};
2123  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2124  }
2125  break;
2126 
2127  // Rose
2128  case 96:
2129  {
2130  Double_t red[9] = { 30./255., 49./255., 79./255., 117./255., 135./255., 151./255., 146./255., 138./255., 147./255.};
2131  Double_t green[9] = { 63./255., 60./255., 72./255., 90./255., 94./255., 94./255., 68./255., 46./255., 16./255.};
2132  Double_t blue[9] = { 18./255., 28./255., 41./255., 56./255., 62./255., 63./255., 50./255., 36./255., 21./255.};
2133  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2134  }
2135  break;
2136 
2137  // Rust
2138  case 97:
2139  {
2140  Double_t red[9] = { 0./255., 30./255., 63./255., 101./255., 143./255., 152./255., 169./255., 187./255., 230./255.};
2141  Double_t green[9] = { 0./255., 14./255., 28./255., 42./255., 58./255., 61./255., 67./255., 74./255., 91./255.};
2142  Double_t blue[9] = { 39./255., 26./255., 21./255., 18./255., 15./255., 14./255., 14./255., 13./255., 13./255.};
2143  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2144  }
2145  break;
2146 
2147  // Sandy Terrain
2148  case 98:
2149  {
2150  Double_t red[9] = { 149./255., 140./255., 164./255., 179./255., 182./255., 181./255., 131./255., 87./255., 61./255.};
2151  Double_t green[9] = { 62./255., 70./255., 107./255., 136./255., 144./255., 138./255., 117./255., 87./255., 74./255.};
2152  Double_t blue[9] = { 40./255., 38./255., 45./255., 49./255., 49./255., 49./255., 38./255., 32./255., 34./255.};
2153  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2154  }
2155  break;
2156 
2157  // Sienna
2158  case 99:
2159  {
2160  Double_t red[9] = { 99./255., 112./255., 148./255., 165./255., 179./255., 182./255., 183./255., 183./255., 208./255.};
2161  Double_t green[9] = { 39./255., 40./255., 57./255., 79./255., 104./255., 127./255., 148./255., 161./255., 198./255.};
2162  Double_t blue[9] = { 15./255., 16./255., 18./255., 33./255., 51./255., 79./255., 103./255., 129./255., 177./255.};
2163  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2164  }
2165  break;
2166 
2167  // Solar
2168  case 100:
2169  {
2170  Double_t red[9] = { 99./255., 116./255., 154./255., 174./255., 200./255., 196./255., 201./255., 201./255., 230./255.};
2171  Double_t green[9] = { 0./255., 0./255., 8./255., 32./255., 58./255., 83./255., 119./255., 136./255., 173./255.};
2172  Double_t blue[9] = { 5./255., 6./255., 7./255., 9./255., 9./255., 14./255., 17./255., 19./255., 24./255.};
2173  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2174  }
2175  break;
2176 
2177  // South West
2178  case 101:
2179  {
2180  Double_t red[9] = { 82./255., 106./255., 126./255., 141./255., 155./255., 163./255., 142./255., 107./255., 66./255.};
2181  Double_t green[9] = { 62./255., 44./255., 69./255., 107./255., 135./255., 152./255., 149./255., 132./255., 119./255.};
2182  Double_t blue[9] = { 39./255., 25./255., 31./255., 60./255., 73./255., 68./255., 49./255., 72./255., 188./255.};
2183  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2184  }
2185  break;
2186 
2187  // Starry Night
2188  case 102:
2189  {
2190  Double_t red[9] = { 18./255., 29./255., 44./255., 72./255., 116./255., 158./255., 184./255., 208./255., 221./255.};
2191  Double_t green[9] = { 27./255., 46./255., 71./255., 105./255., 146./255., 177./255., 189./255., 190./255., 183./255.};
2192  Double_t blue[9] = { 39./255., 55./255., 80./255., 108./255., 130./255., 133./255., 124./255., 100./255., 76./255.};
2193  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2194  }
2195  break;
2196 
2197  // Sunset
2198  case 103:
2199  {
2200  Double_t red[9] = { 0./255., 48./255., 119./255., 173./255., 212./255., 224./255., 228./255., 228./255., 245./255.};
2201  Double_t green[9] = { 0./255., 13./255., 30./255., 47./255., 79./255., 127./255., 167./255., 205./255., 245./255.};
2202  Double_t blue[9] = { 0./255., 68./255., 75./255., 43./255., 16./255., 22./255., 55./255., 128./255., 245./255.};
2203  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2204  }
2205  break;
2206 
2207  // Temperature Map
2208  case 104:
2209  {
2210  Double_t red[9] = { 34./255., 70./255., 129./255., 187./255., 225./255., 226./255., 216./255., 193./255., 179./255.};
2211  Double_t green[9] = { 48./255., 91./255., 147./255., 194./255., 226./255., 229./255., 196./255., 110./255., 12./255.};
2212  Double_t blue[9] = { 234./255., 212./255., 216./255., 224./255., 206./255., 110./255., 53./255., 40./255., 29./255.};
2213  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2214  }
2215  break;
2216 
2217  // Thermometer
2218  case 105:
2219  {
2220  Double_t red[9] = { 30./255., 55./255., 103./255., 147./255., 174./255., 203./255., 188./255., 151./255., 105./255.};
2221  Double_t green[9] = { 0./255., 65./255., 138./255., 182./255., 187./255., 175./255., 121./255., 53./255., 9./255.};
2222  Double_t blue[9] = { 191./255., 202./255., 212./255., 208./255., 171./255., 140./255., 97./255., 57./255., 30./255.};
2223  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2224  }
2225  break;
2226 
2227  // Valentine
2228  case 106:
2229  {
2230  Double_t red[9] = { 112./255., 97./255., 113./255., 125./255., 138./255., 159./255., 178./255., 188./255., 225./255.};
2231  Double_t green[9] = { 16./255., 17./255., 24./255., 37./255., 56./255., 81./255., 110./255., 136./255., 189./255.};
2232  Double_t blue[9] = { 38./255., 35./255., 46./255., 59./255., 78./255., 103./255., 130./255., 152./255., 201./255.};
2233  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2234  }
2235  break;
2236 
2237  // Visible Spectrum
2238  case 107:
2239  {
2240  Double_t red[9] = { 18./255., 72./255., 5./255., 23./255., 29./255., 201./255., 200./255., 98./255., 29./255.};
2241  Double_t green[9] = { 0./255., 0./255., 43./255., 167./255., 211./255., 117./255., 0./255., 0./255., 0./255.};
2242  Double_t blue[9] = { 51./255., 203./255., 177./255., 26./255., 10./255., 9./255., 8./255., 3./255., 0./255.};
2243  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2244  }
2245  break;
2246 
2247  // Water Melon
2248  case 108:
2249  {
2250  Double_t red[9] = { 19./255., 42./255., 64./255., 88./255., 118./255., 147./255., 175./255., 187./255., 205./255.};
2251  Double_t green[9] = { 19./255., 55./255., 89./255., 125./255., 154./255., 169./255., 161./255., 129./255., 70./255.};
2252  Double_t blue[9] = { 19./255., 32./255., 47./255., 70./255., 100./255., 128./255., 145./255., 130./255., 75./255.};
2253  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2254  }
2255  break;
2256 
2257  // Cool
2258  case 109:
2259  {
2260  Double_t red[9] = { 33./255., 31./255., 42./255., 68./255., 86./255., 111./255., 141./255., 172./255., 227./255.};
2261  Double_t green[9] = { 255./255., 175./255., 145./255., 106./255., 88./255., 55./255., 15./255., 0./255., 0./255.};
2262  Double_t blue[9] = { 255./255., 205./255., 202./255., 203./255., 208./255., 205./255., 203./255., 206./255., 231./255.};
2263  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2264  }
2265  break;
2266 
2267  // Copper
2268  case 110:
2269  {
2270  Double_t red[9] = { 0./255., 25./255., 50./255., 79./255., 110./255., 145./255., 181./255., 201./255., 254./255.};
2271  Double_t green[9] = { 0./255., 16./255., 30./255., 46./255., 63./255., 82./255., 101./255., 124./255., 179./255.};
2272  Double_t blue[9] = { 0./255., 12./255., 21./255., 29./255., 39./255., 49./255., 61./255., 74./255., 103./255.};
2273  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2274  }
2275  break;
2276 
2277  // Gist Earth
2278  case 111:
2279  {
2280  Double_t red[9] = { 0./255., 13./255., 30./255., 44./255., 72./255., 120./255., 156./255., 200./255., 247./255.};
2281  Double_t green[9] = { 0./255., 36./255., 84./255., 117./255., 141./255., 153./255., 151./255., 158./255., 247./255.};
2282  Double_t blue[9] = { 0./255., 94./255., 100./255., 82./255., 56./255., 66./255., 76./255., 131./255., 247./255.};
2283  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2284  }
2285  break;
2286 
2287  // Viridis
2288  case 112:
2289  {
2290  Double_t red[9] = { 26./255., 51./255., 43./255., 33./255., 28./255., 35./255., 74./255., 144./255., 246./255.};
2291  Double_t green[9] = { 9./255., 24./255., 55./255., 87./255., 118./255., 150./255., 180./255., 200./255., 222./255.};
2292  Double_t blue[9] = { 30./255., 96./255., 112./255., 114./255., 112./255., 101./255., 72./255., 35./255., 0./255.};
2293  TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2294  }
2295  break;
2296 
2297  default:
2298  ::Error("SetPalette", "Unknown palette number %d", ncolors);
2299  return;
2300  }
2301  paletteType = ncolors;
2302  return;
2303  }
2304 
2305  // set user defined palette
2306  fgPalette.Set(ncolors);
2307  if (colors) for (i=0;i<ncolors;i++) fgPalette.fArray[i] = colors[i];
2308  else for (i=0;i<ncolors;i++) fgPalette.fArray[i] = palette[i];
2309  paletteType = 3;
2310 }
2311 
UShort_t fBlue
Definition: GuiTypes.h:315
for(Int_t i=0;i< n;i++)
Definition: legend1.C:18
static void HSV2RGB(Float_t h, Float_t s, Float_t v, Float_t &r, Float_t &g, Float_t &b)
Static method to compute RGB from HSV:
Definition: TColor.cxx:777
Float_t fBlue
Definition: TColor.h:53
virtual void SetAlpha(Float_t a)
Definition: TColor.h:95
An array of TObjects.
Definition: TObjArray.h:39
TServerSocket * ss
Definition: hserv2.C:30
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
static Bool_t IsGrayscale()
Return whether all colors return grayscale values.
Definition: TColor.cxx:1362
#define fgPalette
Definition: TColor.cxx:37
Float_t fHue
Definition: TColor.h:54
#define fgGrayscaleMode
Definition: TColor.cxx:36
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
float Float_t
Definition: RtypesCore.h:53
Int_t GetLast() const
Return index of last object in array.
Definition: TObjArray.cxx:528
return c
const char Option_t
Definition: RtypesCore.h:62
Definition: Rtypes.h:61
tuple offset
Definition: tree.py:93
static Int_t GetColorDark(Int_t color)
Static function: Returns the dark color number corresponding to n If the TColor object does not exist...
Definition: TColor.cxx:1165
unsigned short UShort_t
Definition: RtypesCore.h:36
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
TH1 * h
Definition: legend2.C:5
Definition: Rtypes.h:60
static void SaveColor(std::ostream &out, Int_t ci)
Save a color with index > 228 as a C++ statement(s) on output stream out.
Definition: TColor.cxx:1324
Definition: Rtypes.h:60
const Mask_t kDoRed
Definition: GuiTypes.h:320
Definition: Rtypes.h:62
static void RGB2HSV(Float_t r, Float_t g, Float_t b, Float_t &h, Float_t &s, Float_t &v)
Static method to compute HSV from RGB.
Definition: TColor.cxx:909
const Mask_t kDoGreen
Definition: GuiTypes.h:321
static Int_t GetNumberOfColors()
Static function returning number of colors in the color palette.
Definition: TColor.cxx:684
#define gROOT
Definition: TROOT.h:344
virtual void ls(Option_t *option="") const
List this color with its attributes.
Definition: TColor.cxx:833
Basic string class.
Definition: TString.h:137
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:170
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
static void HLStoRGB(Float_t h, Float_t l, Float_t s, Float_t &r, Float_t &g, Float_t &b)
Definition: TColor.h:101
const Bool_t kFALSE
Definition: Rtypes.h:92
Float_t GetGreen() const
Definition: TColor.h:86
Definition: Rtypes.h:61
Definition: Rtypes.h:61
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
ULong_t GetPixel() const
Return pixel value corresponding to this color.
Definition: TColor.cxx:694
TFile * f
Array of integers (32 bits per element).
Definition: TArrayI.h:29
Float_t fAlpha
Definition: TColor.h:57
static void SetPalette(Int_t ncolors, Int_t *colors, Float_t alpha=1.)
Static function.
Definition: TColor.cxx:1642
static const char * PixelAsHexString(ULong_t pixel)
Convert machine dependent pixel value (obtained via RGB2Pixel or via Number2Pixel() or via TColor::Ge...
Definition: TColor.cxx:1312
const char * Data() const
Definition: TString.h:349
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Definition: TObjArray.cxx:396
UShort_t fRed
Definition: GuiTypes.h:313
static Int_t GetColorPalette(Int_t i)
Static function returning the color number i in current palette.
Definition: TColor.cxx:672
Sequenceable collection abstract base class.
Definition: Rtypes.h:62
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void Class()
Definition: Class.C:29
virtual TObject * Before(const TObject *obj) const =0
Float_t GetBlue() const
Definition: TColor.h:87
Float_t fLight
Definition: TColor.h:55
virtual void Copy(TObject &named) const
Copy this to obj.
Definition: TNamed.cxx:83
Float_t GetLight() const
Definition: TColor.h:89
Float_t fGreen
Definition: TColor.h:52
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b)
Convert r,g,b to graphics system dependent pixel value.
Definition: TColor.cxx:1257
Definition: Rtypes.h:62
char * out
Definition: TBase64.cxx:29
virtual void Print(Option_t *option="") const
Dump this color with its attributes.
Definition: TColor.cxx:842
virtual ~TColor()
Color destructor.
Definition: TColor.cxx:346
Float_t GetSaturation() const
Definition: TColor.h:90
static void RGB2HLS(Float_t r, Float_t g, Float_t b, Float_t &h, Float_t &l, Float_t &s)
Static method to compute HLS from RGB.
Definition: TColor.cxx:851
static void RGBtoHLS(Float_t r, Float_t g, Float_t b, Float_t &h, Float_t &l, Float_t &s)
Definition: TColor.h:106
Definition: Rtypes.h:60
UShort_t fGreen
Definition: GuiTypes.h:314
static void HLS2RGB(Float_t h, Float_t l, Float_t s, Float_t &r, Float_t &g, Float_t &b)
Static method to compute RGB from HLS.
Definition: TColor.cxx:711
static Int_t GetColorBright(Int_t color)
Static function: Returns the bright color number corresponding to n If the TColor object does not exi...
Definition: TColor.cxx:1133
TThread * t[5]
Definition: threadsh1.C:13
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
Definition: TObjArray.cxx:222
static void NeedGraphicsLibs()
Static method.
ROOT::R::TRInterface & r
Definition: Object.C:4
Definition: Rtypes.h:62
Float_t fSaturation
Definition: TColor.h:56
static void CreateColorsRectangle(Int_t offset, const char *name, UChar_t *rgb)
Create the "rectangular" colors in the color wheel.
Definition: TColor.cxx:564
virtual void GetRGB(Float_t &r, Float_t &g, Float_t &b) const
Definition: TColor.h:79
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2308
const char * AsHexString() const
Return color as hexadecimal string.
Definition: TColor.cxx:491
unsigned int UInt_t
Definition: RtypesCore.h:42
char * Form(const char *fmt,...)
double floor(double)
TLine * l
Definition: textangle.C:4
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb"...
Definition: TColor.cxx:1023
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
TColor()
Default constructor.
Definition: TColor.cxx:295
void Warning(const char *location, const char *msgfmt,...)
ULong_t fPixel
Definition: GuiTypes.h:312
#define gVirtualX
Definition: TVirtualX.h:362
static Int_t GetColorTransparent(Int_t color, Float_t a)
Static function: Returns the transparent color number corresponding to n.
Definition: TColor.cxx:1196
Int_t fNumber
Definition: TColor.h:49
static void CreateColorWheel()
Static function steering the creation of all colors in the color wheel.
Definition: TColor.cxx:584
void InitializeGraphics()
Initialize the graphics environment.
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition: TColor.cxx:1219
Color * colors
Definition: X3DBuffer.c:19
virtual Int_t GetSize() const
Definition: TCollection.h:95
double Double_t
Definition: RtypesCore.h:55
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
unsigned long ULong_t
Definition: RtypesCore.h:51
static void CreateColorsGray()
Create the Gray scale colors in the Color Wheel.
Definition: TColor.cxx:528
virtual void SetRGB(Float_t r, Float_t g, Float_t b)
Initialize this color and its associated colors.
Definition: TColor.cxx:962
The color creation and management class.
Definition: TColor.h:47
Float_t GetRed() const
Definition: TColor.h:85
Definition: Rtypes.h:61
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
Float_t fRed
Definition: TColor.h:51
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
const Mask_t kDoBlue
Definition: GuiTypes.h:322
UShort_t fMask
Definition: GuiTypes.h:316
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
static void SetGrayscale(Bool_t set=kTRUE)
Set whether all colors should return grayscale values.
Definition: TColor.cxx:1370
static void CreateColorsCircle(Int_t offset, const char *name, UChar_t *rgb)
Create the "circle" colors in the color wheel.
Definition: TColor.cxx:544
Definition: Rtypes.h:62
Float_t GetAlpha() const
Definition: TColor.h:91
Double_t dr
Definition: parallelcoord.C:14
float type_of_call hi(const int &, const int &)
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition: TColor.cxx:365
ClassImp(TColor) namespace
Definition: TColor.cxx:23
Definition: Rtypes.h:61
TSocket * s0
Definition: hserv2.C:36
unsigned char UChar_t
Definition: RtypesCore.h:34
Float_t GetHue() const
Definition: TColor.h:88
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
void Allocate()
Make this color known to the graphics system.
Definition: TColor.cxx:1008
const Bool_t kTRUE
Definition: Rtypes.h:91
float * q
Definition: THbookFile.cxx:87
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
TObject * obj
void Copy(TObject &color) const
Copy this color to obj.
Definition: TColor.cxx:512
float value
Definition: math.cpp:443
static Int_t CreateGradientColorTable(UInt_t Number, Double_t *Stops, Double_t *Red, Double_t *Green, Double_t *Blue, UInt_t NColors, Float_t alpha=1.)
Static function creating a color table with several connected linear gradients.
Definition: TColor.cxx:1431
const Int_t n
Definition: legend1.C:16
static Float_t HLStoRGB1(Float_t rn1, Float_t rn2, Float_t huei)
Static method. Auxiliary to HLS2RGB().
Definition: TColor.cxx:736
Definition: Rtypes.h:62
static void Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b)
Convert machine dependent pixel value (obtained via RGB2Pixel or via Number2Pixel() or via TColor::Ge...
Definition: TColor.cxx:1295
virtual TObject * Last() const =0
Int_t GetNumber() const
Definition: TColor.h:83
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904