ROOT  6.06/09
Reference Guide
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 "TArrayI.h"
17 #include "TArrayD.h"
18 #include "TVirtualPad.h"
19 #include "TVirtualX.h"
20 #include "TError.h"
21 #include "TMathBase.h"
22 #include "TApplication.h"
23 #include <cmath>
24 
26 
27 namespace {
28  static Bool_t& TColor__GrayScaleMode() {
29  static Bool_t grayScaleMode;
30  return grayScaleMode;
31  }
32  static TArrayI& TColor__Palette() {
33  static TArrayI globalPalette(0);
34  return globalPalette;
35  }
36  static TArrayD& TColor__PalettesList() {
37  static TArrayD globalPalettesList(0);
38  return globalPalettesList;
39  }
40 }
41 
43 
44 #define fgGrayscaleMode TColor__GrayScaleMode()
45 #define fgPalette TColor__Palette()
46 #define fgPalettesList TColor__PalettesList()
47 
48 using std::floor;
49 
50 /** \class TColor
51 The color creation and management class.
52 
53  - [Introduction](#C00)
54  - [Basic colors](#C01)
55  - [The color wheel](#C02)
56  - [Bright and dark colors](#C03)
57  - [Gray scale view of of canvas with colors](#C04)
58  - [Color palettes](#C05)
59  - [High quality predefined palettes](#C06)
60  - [Color transparency](#C07)
61 
62 ## <a name="C00"></a> Introduction
63 
64 Colors are defined by their red, green and blue components, simply called the
65 RGB components. The colors are also known by the hue, light and saturation
66 components also known as the HLS components. When a new color is created the
67 components of both color systems are computed.
68 
69 At initialization time, a table of colors is generated. An existing color can
70 be retrieved by its index:
71 
72 ~~~ {.cpp}
73  TColor *color = gROOT->GetColor(10);
74 ~~~
75 
76 Then it can be manipulated. For example its RGB components can be modified:
77 
78 ~~~ {.cpp}
79  color->SetRGB(0.1, 0.2, 0.3);
80 ~~~
81 
82 A new color can be created the following way:
83 
84 ~~~ {.cpp}
85  Int_t ci = 1756; // color index
86  TColor *color = new TColor(ci, 0.1, 0.2, 0.3);
87 ~~~
88 
89 Two sets of colors are initialized;
90 
91  - The basic colors: colors with index from 0 to 50.
92  - The color wheel: colors with indices from 300 to 1000.
93 
94 ## <a name="C01"></a> Basic colors
95 The following image displays the 50 basic colors.
96 
97 Begin_Macro(source)
98 {
99  TCanvas *c = new TCanvas("c","Fill Area colors",0,0,500,200);
100  c->DrawColorTable();
101  return c;
102 }
103 End_Macro
104 
105 ## <a name="C02"></a> The color wheel
106 The wheel contains the recommended 216 colors to be used in web applications.
107 
108 The colors in the color wheel are created by `TColor::CreateColorWheel`.
109 
110 Using this color set for your text, background or graphics will give your
111 application a consistent appearance across different platforms and browsers.
112 
113 Colors are grouped by hue, the aspect most important in human perception.
114 Touching color chips have the same hue, but with different brightness and
115 vividness.
116 
117 Colors of slightly different hues clash. If you intend to display
118 colors of the same hue together, you should pick them from the same group.
119 
120 Each color chip is identified by a mnemonic (e.g. kYellow) and a number.
121 The keywords, kRed, kBlue, kYellow, kPink, etc are defined in the header file
122 Rtypes.h that is included in all ROOT other header files. It is better
123 to use these keywords in user code instead of hardcoded color numbers, e.g.:
124 ~~~ {.cpp}
125  myObject.SetFillColor(kRed);
126  myObject.SetFillColor(kYellow-10);
127  myLine.SetLineColor(kMagenta+2);
128 ~~~
129 
130 Begin_Macro(source)
131 {
132  TColorWheel *w = new TColorWheel();
133  w->Draw();
134  return w->GetCanvas();
135 }
136 End_Macro
137 
138 ## <a name="C03"></a> Bright and dark colors
139 The dark and bright color are used to give 3-D effects when drawing various
140 boxes (see TWbox, TPave, TPaveText, TPaveLabel, etc).
141 
142  - The dark colors have an index = color_index+100
143  - The bright colors have an index = color_index+150
144  - Two static functions return the bright and dark color number
145  corresponding to a color index. If the bright or dark color does not
146  exist, they are created:
147  ~~~ {.cpp}
148  Int_t dark = TColor::GetColorDark(color_index);
149  Int_t bright = TColor::GetColorBright(color_index);
150  ~~~
151 
152 ## <a name="C04"></a> Grayscale view of of canvas with colors
153 One can toggle between a grayscale preview and the regular colored mode using
154 `TCanvas::SetGrayscale()`. Note that in grayscale mode, access via RGB
155 will return grayscale values according to ITU standards (and close to b&w
156 printer gray-scales), while access via HLS returns de-saturated gray-scales. The
157 image below shows the ROOT color wheel in grayscale mode.
158 
159 Begin_Macro(source)
160 {
161  TColorWheel *w = new TColorWheel();
162  w->Draw();
163  w->GetCanvas()->SetGrayscale();
164  w->GetCanvas()->Modified();
165  w->GetCanvas()->Update();
166  return w->GetCanvas();
167 }
168 End_Macro
169 
170 ## <a name="C05"></a> Color palettes
171 It is often very useful to represent a variable with a color map. The concept
172 of "color palette" allows to do that. One color palette is active at any time.
173 This "current palette" is set using:
174 
175 ~~~ {.cpp}
176 gStyle->SetPalette(...);
177 ~~~
178 
179 This function has two parameters: the number of colors in the palette and an
180 array of containing the indices of colors in the palette. The following small
181 example demonstrates how to define and use the color palette:
182 
183 Begin_Macro(source)
184 {
185  TCanvas *c1 = new TCanvas("c1","c1",0,0,600,400);
186  TF2 *f1 = new TF2("f1","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",1,3,1,3);
187  Int_t palette[5];
188  palette[0] = 15;
189  palette[1] = 20;
190  palette[2] = 23;
191  palette[3] = 30;
192  palette[4] = 32;
193  gStyle->SetPalette(5,palette);
194  f1->Draw("colz");
195  return c1;
196 }
197 End_Macro
198 
199  To define more a complex palette with a continuous gradient of color, one
200 should use the static function `TColor::CreateGradientColorTable()`.
201 The following example demonstrates how to proceed:
202 
203 Begin_Macro(source)
204 {
205  TCanvas *c2 = new TCanvas("c2","c2",0,0,600,400);
206  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",1,3,1,3);
207  const Int_t Number = 3;
208  Double_t Red[Number] = { 1.00, 0.00, 0.00};
209  Double_t Green[Number] = { 0.00, 1.00, 0.00};
210  Double_t Blue[Number] = { 1.00, 0.00, 1.00};
211  Double_t Length[Number] = { 0.00, 0.50, 1.00 };
212  Int_t nb=50;
213  TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);
214  f2->SetContour(nb);
215  f2->SetLineWidth(1);
216  f2->SetLineColor(kBlack);
217  f2->Draw("surf1z");
218  return c2;
219 }
220 End_Macro
221 
222 The function `TColor::CreateGradientColorTable()` automatically
223 calls `gStyle->SetPalette()`, so there is not need to add one.
224 
225 After a call to `TColor::CreateGradientColorTable()` it is sometimes
226 useful to store the newly create palette for further use. In particular, it is
227 recommended to do if one wants to switch between several user define palettes.
228 To store a palette in an array it is enough to do:
229 
230 ~~~ {.cpp}
231  Int_t MyPalette[100];
232  Double_t r[] = {0., 0.0, 1.0, 1.0, 1.0};
233  Double_t g[] = {0., 0.0, 0.0, 1.0, 1.0};
234  Double_t b[] = {0., 1.0, 0.0, 0.0, 1.0};
235  Double_t stop[] = {0., .25, .50, .75, 1.0};
236  Int_t FI = TColor::CreateGradientColorTable(5, stop, r, g, b, 100);
237  for (int i=0;i<100;i++) MyPalette[i] = FI+i;
238 ~~~
239 
240 Later on to reuse the palette `MyPalette` it will be enough to do
241 
242 ~~~ {.cpp}
243  gStyle->SetPalette(100, MyPalette);
244 ~~~
245 
246 As only one palette is active, one need to use `TExec` to be able to
247 display plots using different palettes on the same pad.
248 The following macro illustrate this feature.
249 
250 Begin_Macro(source)
251 ../../../tutorials/graphs/multipalette.C
252 End_Macro
253 
254 ## <a name="C06"></a> High quality predefined palettes
255 \since **6.04:**
256 62 high quality palettes are predefined with 255 colors each.
257 These palettes can be accessed "by name" with `gStyle->SetPalette(num)`.
258 `num` can be taken within the following enum:
259 
260 ~~~ {.cpp}
261 kDeepSea=51, kGreyScale=52, kDarkBodyRadiator=53,
262 kBlueYellow= 54, kRainBow=55, kInvertedDarkBodyRadiator=56,
263 kBird=57, kCubehelix=58, kGreenRedViolet=59,
264 kBlueRedYellow=60, kOcean=61, kColorPrintableOnGrey=62,
265 kAlpine=63, kAquamarine=64, kArmy=65,
266 kAtlantic=66, kAurora=67, kAvocado=68,
267 kBeach=69, kBlackBody=70, kBlueGreenYellow=71,
268 kBrownCyan=72, kCMYK=73, kCandy=74,
269 kCherry=75, kCoffee=76, kDarkRainBow=77,
270 kDarkTerrain=78, kFall=79, kFruitPunch=80,
271 kFuchsia=81, kGreyYellow=82, kGreenBrownTerrain=83,
272 kGreenPink=84, kIsland=85, kLake=86,
273 kLightTemperature=87, kLightTerrain=88, kMint=89,
274 kNeon=90, kPastel=91, kPearl=92,
275 kPigeon=93, kPlum=94, kRedBlue=95,
276 kRose=96, kRust=97, kSandyTerrain=98,
277 kSienna=99, kSolar=100, kSouthWest=101,
278 kStarryNight=102, kSunset=103, kTemperatureMap=104,
279 kThermometer=105, kValentine=106, kVisibleSpectrum=107,
280 kWaterMelon=108, kCool=109, kCopper=110,
281 kGistEarth=111, kViridis=112
282 ~~~
283 
284 <table border=0>
285 <tr><td>
286 Begin_Macro
287 {
288  c = new TCanvas("c","c",0,0,300,300);
289  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
290  f2->SetContour(99); gStyle->SetPalette(kDeepSea);
291  f2->Draw("surf2Z"); f2->SetTitle("kDeepSea");
292 }
293 End_Macro
294 </td><td>
295 Begin_Macro
296 {
297  c = new TCanvas("c","c",0,0,300,300);
298  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
299  f2->SetContour(99); gStyle->SetPalette(kGreyScale);
300  f2->Draw("surf2Z"); f2->SetTitle("kGreyScale");
301 }
302 End_Macro
303 </td><td>
304 Begin_Macro
305 {
306  c = new TCanvas("c","c",0,0,300,300);
307  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
308  f2->SetContour(99); gStyle->SetPalette(kDarkBodyRadiator);
309  f2->Draw("surf2Z"); f2->SetTitle("kDarkBodyRadiator");
310 }
311 End_Macro
312 </td></tr>
313 <tr><td>
314 Begin_Macro
315 {
316  c = new TCanvas("c","c",0,0,300,300);
317  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
318  f2->SetContour(99); gStyle->SetPalette(kBlueYellow);
319  f2->Draw("surf2Z"); f2->SetTitle("kBlueYellow");
320 }
321 End_Macro
322 </td><td>
323 Begin_Macro
324 {
325  c = new TCanvas("c","c",0,0,300,300);
326  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
327  f2->SetContour(99); gStyle->SetPalette(kRainBow);
328  f2->Draw("surf2Z"); f2->SetTitle("kRainBow");
329 }
330 End_Macro
331 </td><td>
332 Begin_Macro
333 {
334  c = new TCanvas("c","c",0,0,300,300);
335  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
336  f2->SetContour(99); gStyle->SetPalette(kInvertedDarkBodyRadiator);
337  f2->Draw("surf2Z"); f2->SetTitle("kInvertedDarkBodyRadiator");
338 }
339 End_Macro
340 </td></tr>
341 <tr><td>
342 Begin_Macro
343 {
344  c = new TCanvas("c","c",0,0,300,300);
345  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
346  f2->SetContour(99); gStyle->SetPalette(kBird);
347  f2->Draw("surf2Z"); f2->SetTitle("kBird (default)");
348 }
349 End_Macro
350 </td><td>
351 Begin_Macro
352 {
353  c = new TCanvas("c","c",0,0,300,300);
354  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
355  f2->SetContour(99); gStyle->SetPalette(kCubehelix);
356  f2->Draw("surf2Z"); f2->SetTitle("kCubehelix");
357 }
358 End_Macro
359 </td><td>
360 Begin_Macro
361 {
362  c = new TCanvas("c","c",0,0,300,300);
363  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
364  f2->SetContour(99); gStyle->SetPalette(kGreenRedViolet);
365  f2->Draw("surf2Z"); f2->SetTitle("kGreenRedViolet");
366 }
367 End_Macro
368 </td></tr>
369 <tr><td>
370 Begin_Macro
371 {
372  c = new TCanvas("c","c",0,0,300,300);
373  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
374  f2->SetContour(99); gStyle->SetPalette(kBlueRedYellow);
375  f2->Draw("surf2Z"); f2->SetTitle("kBlueRedYellow");
376 }
377 End_Macro
378 </td><td>
379 Begin_Macro
380 {
381  c = new TCanvas("c","c",0,0,300,300);
382  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
383  f2->SetContour(99); gStyle->SetPalette(kOcean);
384  f2->Draw("surf2Z"); f2->SetTitle("kOcean");
385 }
386 End_Macro
387 </td><td>
388 Begin_Macro
389 {
390  c = new TCanvas("c","c",0,0,300,300);
391  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
392  f2->SetContour(99); gStyle->SetPalette(kColorPrintableOnGrey);
393  f2->Draw("surf2Z"); f2->SetTitle("kColorPrintableOnGrey");
394 }
395 End_Macro
396 </td></tr>
397 <tr><td>
398 Begin_Macro
399 {
400  c = new TCanvas("c","c",0,0,300,300);
401  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
402  f2->SetContour(99); gStyle->SetPalette(kAlpine);
403  f2->Draw("surf2Z"); f2->SetTitle("kAlpine");
404 }
405 End_Macro
406 </td><td>
407 Begin_Macro
408 {
409  c = new TCanvas("c","c",0,0,300,300);
410  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
411  f2->SetContour(99); gStyle->SetPalette(kAquamarine);
412  f2->Draw("surf2Z"); f2->SetTitle("kAquamarine");
413 }
414 End_Macro
415 </td><td>
416 Begin_Macro
417 {
418  c = new TCanvas("c","c",0,0,300,300);
419  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
420  f2->SetContour(99); gStyle->SetPalette(kArmy);
421  f2->Draw("surf2Z"); f2->SetTitle("kArmy");
422 }
423 End_Macro
424 </td></tr>
425 <tr><td>
426 Begin_Macro
427 {
428  c = new TCanvas("c","c",0,0,300,300);
429  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
430  f2->SetContour(99); gStyle->SetPalette(kAtlantic);
431  f2->Draw("surf2Z"); f2->SetTitle("kAtlantic");
432 }
433 End_Macro
434 </td><td>
435 Begin_Macro
436 {
437  c = new TCanvas("c","c",0,0,300,300);
438  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
439  f2->SetContour(99); gStyle->SetPalette(kAurora);
440  f2->Draw("surf2Z"); f2->SetTitle("kAurora");
441 }
442 End_Macro
443 </td><td>
444 Begin_Macro
445 {
446  c = new TCanvas("c","c",0,0,300,300);
447  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
448  f2->SetContour(99); gStyle->SetPalette(kAvocado);
449  f2->Draw("surf2Z"); f2->SetTitle("kAvocado");
450 }
451 End_Macro
452 </td></tr>
453 <tr><td>
454 Begin_Macro
455 {
456  c = new TCanvas("c","c",0,0,300,300);
457  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
458  f2->SetContour(99); gStyle->SetPalette(kBeach);
459  f2->Draw("surf2Z"); f2->SetTitle("kBeach");
460 }
461 End_Macro
462 </td><td>
463 Begin_Macro
464 {
465  c = new TCanvas("c","c",0,0,300,300);
466  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
467  f2->SetContour(99); gStyle->SetPalette(kBlackBody);
468  f2->Draw("surf2Z"); f2->SetTitle("kBlackBody");
469 }
470 End_Macro
471 </td><td>
472 Begin_Macro
473 {
474  c = new TCanvas("c","c",0,0,300,300);
475  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
476  f2->SetContour(99); gStyle->SetPalette(kBlueGreenYellow);
477  f2->Draw("surf2Z"); f2->SetTitle("kBlueGreenYellow");
478 }
479 End_Macro
480 </td></tr>
481 <tr><td>
482 Begin_Macro
483 {
484  c = new TCanvas("c","c",0,0,300,300);
485  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
486  f2->SetContour(99); gStyle->SetPalette(kBrownCyan);
487  f2->Draw("surf2Z"); f2->SetTitle("kBrownCyan");
488 }
489 End_Macro
490 </td><td>
491 Begin_Macro
492 {
493  c = new TCanvas("c","c",0,0,300,300);
494  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
495  f2->SetContour(99); gStyle->SetPalette(kCMYK);
496  f2->Draw("surf2Z"); f2->SetTitle("kCMYK");
497 }
498 End_Macro
499 </td><td>
500 Begin_Macro
501 {
502  c = new TCanvas("c","c",0,0,300,300);
503  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
504  f2->SetContour(99); gStyle->SetPalette(kCandy);
505  f2->Draw("surf2Z"); f2->SetTitle("kCandy");
506 }
507 End_Macro
508 </td></tr>
509 <tr><td>
510 Begin_Macro
511 {
512  c = new TCanvas("c","c",0,0,300,300);
513  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
514  f2->SetContour(99); gStyle->SetPalette(kCherry);
515  f2->Draw("surf2Z"); f2->SetTitle("kCherry");
516 }
517 End_Macro
518 </td><td>
519 Begin_Macro
520 {
521  c = new TCanvas("c","c",0,0,300,300);
522  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
523  f2->SetContour(99); gStyle->SetPalette(kCoffee);
524  f2->Draw("surf2Z"); f2->SetTitle("kCoffee");
525 }
526 End_Macro
527 </td><td>
528 Begin_Macro
529 {
530  c = new TCanvas("c","c",0,0,300,300);
531  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
532  f2->SetContour(99); gStyle->SetPalette(kDarkRainBow);
533  f2->Draw("surf2Z"); f2->SetTitle("kDarkRainBow");
534 }
535 End_Macro
536 </td></tr>
537 <tr><td>
538 Begin_Macro
539 {
540  c = new TCanvas("c","c",0,0,300,300);
541  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
542  f2->SetContour(99); gStyle->SetPalette(kDarkTerrain);
543  f2->Draw("surf2Z"); f2->SetTitle("kDarkTerrain");
544 }
545 End_Macro
546 </td><td>
547 Begin_Macro
548 {
549  c = new TCanvas("c","c",0,0,300,300);
550  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
551  f2->SetContour(99); gStyle->SetPalette(kFall);
552  f2->Draw("surf2Z"); f2->SetTitle("kFall");
553 }
554 End_Macro
555 </td><td>
556 Begin_Macro
557 {
558  c = new TCanvas("c","c",0,0,300,300);
559  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
560  f2->SetContour(99); gStyle->SetPalette(kFruitPunch);
561  f2->Draw("surf2Z"); f2->SetTitle("kFruitPunch");
562 }
563 End_Macro
564 </td></tr>
565 <tr><td>
566 Begin_Macro
567 {
568  c = new TCanvas("c","c",0,0,300,300);
569  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
570  f2->SetContour(99); gStyle->SetPalette(kFuchsia);
571  f2->Draw("surf2Z"); f2->SetTitle("kFuchsia");
572 }
573 End_Macro
574 </td><td>
575 Begin_Macro
576 {
577  c = new TCanvas("c","c",0,0,300,300);
578  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
579  f2->SetContour(99); gStyle->SetPalette(kGreyYellow);
580  f2->Draw("surf2Z"); f2->SetTitle("kGreyYellow");
581 }
582 End_Macro
583 </td><td>
584 Begin_Macro
585 {
586  c = new TCanvas("c","c",0,0,300,300);
587  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
588  f2->SetContour(99); gStyle->SetPalette(kGreenBrownTerrain);
589  f2->Draw("surf2Z"); f2->SetTitle("kGreenBrownTerrain");
590 }
591 End_Macro
592 </td></tr>
593 <tr><td>
594 Begin_Macro
595 {
596  c = new TCanvas("c","c",0,0,300,300);
597  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
598  f2->SetContour(99); gStyle->SetPalette(kGreenPink);
599  f2->Draw("surf2Z"); f2->SetTitle("kGreenPink");
600 }
601 End_Macro
602 </td><td>
603 Begin_Macro
604 {
605  c = new TCanvas("c","c",0,0,300,300);
606  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
607  f2->SetContour(99); gStyle->SetPalette(kIsland);
608  f2->Draw("surf2Z"); f2->SetTitle("kIsland");
609 }
610 End_Macro
611 </td><td>
612 Begin_Macro
613 {
614  c = new TCanvas("c","c",0,0,300,300);
615  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
616  f2->SetContour(99); gStyle->SetPalette(kLake);
617  f2->Draw("surf2Z"); f2->SetTitle("kLake");
618 }
619 End_Macro
620 </td></tr>
621 <tr><td>
622 Begin_Macro
623 {
624  c = new TCanvas("c","c",0,0,300,300);
625  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
626  f2->SetContour(99); gStyle->SetPalette(kLightTemperature);
627  f2->Draw("surf2Z"); f2->SetTitle("kLightTemperature");
628 }
629 End_Macro
630 </td><td>
631 Begin_Macro
632 {
633  c = new TCanvas("c","c",0,0,300,300);
634  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
635  f2->SetContour(99); gStyle->SetPalette(kLightTerrain);
636  f2->Draw("surf2Z"); f2->SetTitle("kLightTerrain");
637 }
638 End_Macro
639 </td><td>
640 Begin_Macro
641 {
642  c = new TCanvas("c","c",0,0,300,300);
643  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
644  f2->SetContour(99); gStyle->SetPalette(kMint);
645  f2->Draw("surf2Z"); f2->SetTitle("kMint");
646 }
647 End_Macro
648 </td></tr>
649 <tr><td>
650 Begin_Macro
651 {
652  c = new TCanvas("c","c",0,0,300,300);
653  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
654  f2->SetContour(99); gStyle->SetPalette(kNeon);
655  f2->Draw("surf2Z"); f2->SetTitle("kNeon");
656 }
657 End_Macro
658 </td><td>
659 Begin_Macro
660 {
661  c = new TCanvas("c","c",0,0,300,300);
662  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
663  f2->SetContour(99); gStyle->SetPalette(kPastel);
664  f2->Draw("surf2Z"); f2->SetTitle("kPastel");
665 }
666 End_Macro
667 </td><td>
668 Begin_Macro
669 {
670  c = new TCanvas("c","c",0,0,300,300);
671  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
672  f2->SetContour(99); gStyle->SetPalette(kPearl);
673  f2->Draw("surf2Z"); f2->SetTitle("kPearl");
674 }
675 End_Macro
676 </td></tr>
677 <tr><td>
678 Begin_Macro
679 {
680  c = new TCanvas("c","c",0,0,300,300);
681  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
682  f2->SetContour(99); gStyle->SetPalette(kPigeon);
683  f2->Draw("surf2Z"); f2->SetTitle("kPigeon");
684 }
685 End_Macro
686 </td><td>
687 Begin_Macro
688 {
689  c = new TCanvas("c","c",0,0,300,300);
690  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
691  f2->SetContour(99); gStyle->SetPalette(kPlum);
692  f2->Draw("surf2Z"); f2->SetTitle("kPlum");
693 }
694 End_Macro
695 </td><td>
696 Begin_Macro
697 {
698  c = new TCanvas("c","c",0,0,300,300);
699  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
700  f2->SetContour(99); gStyle->SetPalette(kRedBlue);
701  f2->Draw("surf2Z"); f2->SetTitle("kRedBlue");
702 }
703 End_Macro
704 </td></tr>
705 <tr><td>
706 Begin_Macro
707 {
708  c = new TCanvas("c","c",0,0,300,300);
709  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
710  f2->SetContour(99); gStyle->SetPalette(kRose);
711  f2->Draw("surf2Z"); f2->SetTitle("kRose");
712 }
713 End_Macro
714 </td><td>
715 Begin_Macro
716 {
717  c = new TCanvas("c","c",0,0,300,300);
718  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
719  f2->SetContour(99); gStyle->SetPalette(kRust);
720  f2->Draw("surf2Z"); f2->SetTitle("kRust");
721 }
722 End_Macro
723 </td><td>
724 Begin_Macro
725 {
726  c = new TCanvas("c","c",0,0,300,300);
727  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
728  f2->SetContour(99); gStyle->SetPalette(kSandyTerrain);
729  f2->Draw("surf2Z"); f2->SetTitle("kSandyTerrain");
730 }
731 End_Macro
732 </td></tr>
733 <tr><td>
734 Begin_Macro
735 {
736  c = new TCanvas("c","c",0,0,300,300);
737  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
738  f2->SetContour(99); gStyle->SetPalette(kSienna);
739  f2->Draw("surf2Z"); f2->SetTitle("kSienna");
740 }
741 End_Macro
742 </td><td>
743 Begin_Macro
744 {
745  c = new TCanvas("c","c",0,0,300,300);
746  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
747  f2->SetContour(99); gStyle->SetPalette(kSolar);
748  f2->Draw("surf2Z"); f2->SetTitle("kSolar");
749 }
750 End_Macro
751 </td><td>
752 Begin_Macro
753 {
754  c = new TCanvas("c","c",0,0,300,300);
755  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
756  f2->SetContour(99); gStyle->SetPalette(kSouthWest);
757  f2->Draw("surf2Z"); f2->SetTitle("kSouthWest");
758 }
759 End_Macro
760 </td></tr>
761 <tr><td>
762 Begin_Macro
763 {
764  c = new TCanvas("c","c",0,0,300,300);
765  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
766  f2->SetContour(99); gStyle->SetPalette(kStarryNight);
767  f2->Draw("surf2Z"); f2->SetTitle("kStarryNight");
768 }
769 End_Macro
770 </td><td>
771 Begin_Macro
772 {
773  c = new TCanvas("c","c",0,0,300,300);
774  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
775  f2->SetContour(99); gStyle->SetPalette(kSunset);
776  f2->Draw("surf2Z"); f2->SetTitle("kSunset");
777 }
778 End_Macro
779 </td><td>
780 Begin_Macro
781 {
782  c = new TCanvas("c","c",0,0,300,300);
783  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
784  f2->SetContour(99); gStyle->SetPalette(kTemperatureMap);
785  f2->Draw("surf2Z"); f2->SetTitle("kTemperatureMap");
786 }
787 End_Macro
788 </td></tr>
789 <tr><td>
790 Begin_Macro
791 {
792  c = new TCanvas("c","c",0,0,300,300);
793  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
794  f2->SetContour(99); gStyle->SetPalette(kThermometer);
795  f2->Draw("surf2Z"); f2->SetTitle("kThermometer");
796 }
797 End_Macro
798 </td><td>
799 Begin_Macro
800 {
801  c = new TCanvas("c","c",0,0,300,300);
802  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
803  f2->SetContour(99); gStyle->SetPalette(kValentine);
804  f2->Draw("surf2Z"); f2->SetTitle("kValentine");
805 }
806 End_Macro
807 </td><td>
808 Begin_Macro
809 {
810  c = new TCanvas("c","c",0,0,300,300);
811  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
812  f2->SetContour(99); gStyle->SetPalette(kVisibleSpectrum);
813  f2->Draw("surf2Z"); f2->SetTitle("kVisibleSpectrum");
814 }
815 End_Macro
816 </td></tr>
817 <tr><td>
818 Begin_Macro
819 {
820  c = new TCanvas("c","c",0,0,300,300);
821  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
822  f2->SetContour(99); gStyle->SetPalette(kWaterMelon);
823  f2->Draw("surf2Z"); f2->SetTitle("kWaterMelon");
824 }
825 End_Macro
826 </td><td>
827 Begin_Macro
828 {
829  c = new TCanvas("c","c",0,0,300,300);
830  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
831  f2->SetContour(99); gStyle->SetPalette(kCool);
832  f2->Draw("surf2Z"); f2->SetTitle("kCool");
833 }
834 End_Macro
835 </td><td>
836 Begin_Macro
837 {
838  c = new TCanvas("c","c",0,0,300,300);
839  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
840  f2->SetContour(99); gStyle->SetPalette(kCopper);
841  f2->Draw("surf2Z"); f2->SetTitle("kCopper");
842 }
843 End_Macro
844 </td></tr>
845 <tr><td>
846 Begin_Macro
847 {
848  c = new TCanvas("c","c",0,0,300,300);
849  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
850  f2->SetContour(99); gStyle->SetPalette(kGistEarth);
851  f2->Draw("surf2Z"); f2->SetTitle("kGistEarth");
852 }
853 End_Macro
854 </td><td>
855 Begin_Macro
856 {
857  c = new TCanvas("c","c",0,0,300,300);
858  TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002);
859  f2->SetContour(99); gStyle->SetPalette(kViridis);
860  f2->Draw("surf2Z"); f2->SetTitle("kViridis");
861 }
862 End_Macro
863 </td></tr>
864 </table>
865 
866 ## <a name="C07"></a> Color transparency
867 To make a graphics object transparent it is enough to set its color to a
868 transparent one. The color transparency is defined via its alpha component. The
869 alpha value varies from `0.` (fully transparent) to `1.` (fully
870 opaque). To set the alpha value of an existing color it is enough to do:
871 
872 ~~~ {.cpp}
873  TColor *col26 = gROOT->GetColor(26);
874  col26->SetAlpha(0.01);
875 ~~~
876 
877 A new color can be created transparent the following way:
878 
879 ~~~ {.cpp}
880  Int_t ci = 1756;
881  TColor *color = new TColor(ci, 0.1, 0.2, 0.3, "", 0.5); // alpha = 0.5
882 ~~~
883 
884 An example of transparency usage with parallel coordinates can be found
885 in `$ROOTSYS/tutorials/tree/parallelcoordtrans.C`.
886 
887 To ease the creation of a transparent color the static method
888 `GetColorTransparent(Int_t color, Float_t a)` is provided.
889 In the following example the `trans_red` color index point to
890 a red color 30% transparent. The alpha value of the color index
891 `kRed` is not modified.
892 
893 ~~~ {.cpp}
894  Int_t trans_red = GetColorTransparent(kRed, 0.3);
895 ~~~
896 
897 This function is also used in the methods
898 `SetFillColorAlpha()`, `SetLineColorAlpha()`,
899 `SetMarkerColorAlpha()` and `SetTextColorAlpha()`.
900 In the following example the fill color of the histogram `histo`
901 is set to blue with a transparency of 35%. The color `kBlue`
902 itself remains fully opaque.
903 
904 ~~~ {.cpp}
905  histo->SetFillColorAlpha(kBlue, 0.35);
906 ~~~
907 
908 The transparency is available on all platforms when the flag `OpenGL.CanvasPreferGL` is set to `1`
909 in `$ROOTSYS/etc/system.rootrc`, or on Mac with the Cocoa backend. On the file output
910 it is visible with PDF, PNG, Gif, JPEG, SVG ... but not PostScript.
911  */
912 
913 ////////////////////////////////////////////////////////////////////////////////
914 /// Default constructor.
915 
917 {
918  fNumber = -1;
919  fRed = fGreen = fBlue = fHue = fLight = fSaturation = -1;
920  fAlpha = 1;
921 }
922 
923 ////////////////////////////////////////////////////////////////////////////////
924 /// Normal color constructor. Initialize a color structure.
925 /// Compute the RGB and HLS color components.
926 
927 TColor::TColor(Int_t color, Float_t r, Float_t g, Float_t b, const char *name,
929  : TNamed(name,"")
930 {
932  // do not enter if color number already exist
933  TColor *col = gROOT->GetColor(color);
934  if (col) {
935  Warning("TColor", "color %d already defined", color);
936  fNumber = col->GetNumber();
937  fRed = col->GetRed();
938  fGreen = col->GetGreen();
939  fBlue = col->GetBlue();
940  fHue = col->GetHue();
941  fLight = col->GetLight();
942  fAlpha = col->GetAlpha();
943  fSaturation = col->GetSaturation();
944  return;
945  }
946 
947  fNumber = color;
948 
950 
951  char aname[32];
952  if (!name || !*name) {
953  snprintf(aname,32, "Color%d", color);
954  SetName(aname);
955  }
956 
957  // enter in the list of colors
958  TObjArray *lcolors = (TObjArray*)gROOT->GetListOfColors();
959  lcolors->AddAtAndExpand(this, color);
960 
961  // fill color structure
962  SetRGB(r, g, b);
963  fAlpha = a;
964 }
965 
966 ////////////////////////////////////////////////////////////////////////////////
967 /// Fast TColor constructor. It creates a color with an index just above the
968 /// current highest one. It does not name the color.
969 /// This is useful to create palettes.
970 
972 {
974  fNumber = gHighestColorIndex;
975  fRed = r;
976  fGreen = g;
977  fBlue = b;
978  fAlpha = a;
979 
980  // enter in the list of colors
981  TObjArray *lcolors = (TObjArray*)gROOT->GetListOfColors();
982  lcolors->AddAtAndExpand(this, fNumber);
983 }
984 
985 ////////////////////////////////////////////////////////////////////////////////
986 /// Color destructor.
987 
989 {
990  gROOT->GetListOfColors()->Remove(this);
991  if (gROOT->GetListOfColors()->GetEntries() == 0) {fgPalette.Set(0); fgPalette=0;}
992 }
993 
994 ////////////////////////////////////////////////////////////////////////////////
995 /// Color copy constructor.
996 
997 TColor::TColor(const TColor &color) : TNamed(color)
998 {
999  ((TColor&)color).Copy(*this);
1000 }
1001 
1002 ////////////////////////////////////////////////////////////////////////////////
1003 /// Initialize colors used by the TCanvas based graphics (via TColor objects).
1004 /// This method should be called before the ApplicationImp is created (which
1005 /// initializes the GUI colors).
1006 
1009  static Bool_t initDone = kFALSE;
1010 
1011  if (initDone) return;
1012  initDone = kTRUE;
1013 
1014  if (gROOT->GetListOfColors()->First() == 0) {
1015 
1016  new TColor(kWhite,1,1,1,"background");
1017  new TColor(kBlack,0,0,0,"black");
1018  new TColor(2,1,0,0,"red");
1019  new TColor(3,0,1,0,"green");
1020  new TColor(4,0,0,1,"blue");
1021  new TColor(5,1,1,0,"yellow");
1022  new TColor(6,1,0,1,"magenta");
1023  new TColor(7,0,1,1,"cyan");
1024  new TColor(10,0.999,0.999,0.999,"white");
1025  new TColor(11,0.754,0.715,0.676,"editcol");
1026 
1027  // The color white above is defined as being nearly white.
1028  // Sets the associated dark color also to white.
1030  TColor *c110 = gROOT->GetColor(110);
1031  if (c110) c110->SetRGB(0.999,0.999,.999);
1032 
1033  // Initialize Custom colors
1034  new TColor(20,0.8,0.78,0.67);
1035  new TColor(31,0.54,0.66,0.63);
1036  new TColor(41,0.83,0.81,0.53);
1037  new TColor(30,0.52,0.76,0.64);
1038  new TColor(32,0.51,0.62,0.55);
1039  new TColor(24,0.70,0.65,0.59);
1040  new TColor(21,0.8,0.78,0.67);
1041  new TColor(47,0.67,0.56,0.58);
1042  new TColor(35,0.46,0.54,0.57);
1043  new TColor(33,0.68,0.74,0.78);
1044  new TColor(39,0.5,0.5,0.61);
1045  new TColor(37,0.43,0.48,0.52);
1046  new TColor(38,0.49,0.6,0.82);
1047  new TColor(36,0.41,0.51,0.59);
1048  new TColor(49,0.58,0.41,0.44);
1049  new TColor(43,0.74,0.62,0.51);
1050  new TColor(22,0.76,0.75,0.66);
1051  new TColor(45,0.75,0.51,0.47);
1052  new TColor(44,0.78,0.6,0.49);
1053  new TColor(26,0.68,0.6,0.55);
1054  new TColor(28,0.53,0.4,0.34);
1055  new TColor(25,0.72,0.64,0.61);
1056  new TColor(27,0.61,0.56,0.51);
1057  new TColor(23,0.73,0.71,0.64);
1058  new TColor(42,0.87,0.73,0.53);
1059  new TColor(46,0.81,0.37,0.38);
1060  new TColor(48,0.65,0.47,0.48);
1061  new TColor(34,0.48,0.56,0.6);
1062  new TColor(40,0.67,0.65,0.75);
1063  new TColor(29,0.69,0.81,0.78);
1064 
1065  // Initialize some additional greyish non saturated colors
1066  new TColor(8, 0.35,0.83,0.33);
1067  new TColor(9, 0.35,0.33,0.85);
1068  new TColor(12,.3,.3,.3,"grey12");
1069  new TColor(13,.4,.4,.4,"grey13");
1070  new TColor(14,.5,.5,.5,"grey14");
1071  new TColor(15,.6,.6,.6,"grey15");
1072  new TColor(16,.7,.7,.7,"grey16");
1073  new TColor(17,.8,.8,.8,"grey17");
1074  new TColor(18,.9,.9,.9,"grey18");
1075  new TColor(19,.95,.95,.95,"grey19");
1076  new TColor(50, 0.83,0.35,0.33);
1077 
1078  // Initialize the Pretty Palette Spectrum Violet->Red
1079  // The color model used here is based on the HLS model which
1080  // is much more suitable for creating palettes than RGB.
1081  // Fixing the saturation and lightness we can scan through the
1082  // spectrum of visible light by using "hue" alone.
1083  // In Root hue takes values from 0 to 360.
1084  Int_t i;
1085  Float_t saturation = 1;
1086  Float_t lightness = 0.5;
1087  Float_t maxHue = 280;
1088  Float_t minHue = 0;
1089  Int_t maxPretty = 50;
1090  Float_t hue;
1091  Float_t r=0., g=0., b=0., h, l, s;
1092 
1093  for (i=0 ; i<maxPretty ; i++) {
1094  hue = maxHue-(i+1)*((maxHue-minHue)/maxPretty);
1095  TColor::HLStoRGB(hue, lightness, saturation, r, g, b);
1096  new TColor(i+51, r, g, b);
1097  }
1098 
1099  // Initialize special colors for x3d
1100  TColor *s0;
1101  for (i = 1; i < 8; i++) {
1102  s0 = gROOT->GetColor(i);
1103  if (s0) s0->GetRGB(r,g,b);
1104  if (i == 1) { r = 0.6; g = 0.6; b = 0.6; }
1105  if (r == 1) r = 0.9; else if (r == 0) r = 0.1;
1106  if (g == 1) g = 0.9; else if (g == 0) g = 0.1;
1107  if (b == 1) b = 0.9; else if (b == 0) b = 0.1;
1108  TColor::RGBtoHLS(r,g,b,h,l,s);
1109  TColor::HLStoRGB(h,0.6*l,s,r,g,b);
1110  new TColor(200+4*i-3,r,g,b);
1111  TColor::HLStoRGB(h,0.8*l,s,r,g,b);
1112  new TColor(200+4*i-2,r,g,b);
1113  TColor::HLStoRGB(h,1.2*l,s,r,g,b);
1114  new TColor(200+4*i-1,r,g,b);
1115  TColor::HLStoRGB(h,1.4*l,s,r,g,b);
1116  new TColor(200+4*i ,r,g,b);
1117  }
1118 
1119  // Create the ROOT Color Wheel
1121  }
1122  // If fgPalette.fN !=0 SetPalette has been called already
1123  // (from rootlogon.C for instance)
1124 
1125  if (!fgPalette.fN) SetPalette(1,0);
1126 }
1127 
1128 ////////////////////////////////////////////////////////////////////////////////
1129 /// Return color as hexadecimal string. This string can be directly passed
1130 /// to, for example, TGClient::GetColorByName(). String will be reused so
1131 /// copy immediately if needed.
1132 
1133 const char *TColor::AsHexString() const
1135  static TString tempbuf;
1136 
1137  Int_t r, g, b, a;
1138  r = Int_t(GetRed() * 255);
1139  g = Int_t(GetGreen() * 255);
1140  b = Int_t(GetBlue() * 255);
1141  a = Int_t(fAlpha * 255);
1142 
1143  if (a != 255) {
1144  tempbuf.Form("#%02x%02x%02x%02x", a, r, g, b);
1145  } else {
1146  tempbuf.Form("#%02x%02x%02x", r, g, b);
1147  }
1148  return tempbuf;
1149 }
1150 
1151 ////////////////////////////////////////////////////////////////////////////////
1152 /// Copy this color to obj.
1153 
1154 void TColor::Copy(TObject &obj) const
1156  TNamed::Copy((TNamed&)obj);
1157  ((TColor&)obj).fRed = fRed;
1158  ((TColor&)obj).fGreen = fGreen;
1159  ((TColor&)obj).fBlue = fBlue;
1160  ((TColor&)obj).fHue = fHue;
1161  ((TColor&)obj).fLight = fLight;
1162  ((TColor&)obj).fAlpha = fAlpha;
1163  ((TColor&)obj).fSaturation = fSaturation;
1164  ((TColor&)obj).fNumber = fNumber;
1165 }
1166 
1167 ////////////////////////////////////////////////////////////////////////////////
1168 /// Create the Gray scale colors in the Color Wheel
1169 
1172  if (gROOT->GetColor(kGray)) return;
1173  TColor *gray = new TColor(kGray,204./255.,204./255.,204./255.);
1174  TColor *gray1 = new TColor(kGray+1,153./255.,153./255.,153./255.);
1175  TColor *gray2 = new TColor(kGray+2,102./255.,102./255.,102./255.);
1176  TColor *gray3 = new TColor(kGray+3, 51./255., 51./255., 51./255.);
1177  gray ->SetName("kGray");
1178  gray1->SetName("kGray+1");
1179  gray2->SetName("kGray+2");
1180  gray3->SetName("kGray+3");
1181 }
1182 
1183 ////////////////////////////////////////////////////////////////////////////////
1184 /// Create the "circle" colors in the color wheel.
1185 
1186 void TColor::CreateColorsCircle(Int_t offset, const char *name, UChar_t *rgb)
1188  TString colorname;
1189  for (Int_t n=0;n<15;n++) {
1190  Int_t colorn = offset+n-10;
1191  TColor *color = gROOT->GetColor(colorn);
1192  if (!color) {
1193  color = new TColor(colorn,rgb[3*n]/255.,rgb[3*n+1]/255.,rgb[3*n+2]/255.);
1194  color->SetTitle(color->AsHexString());
1195  if (n>10) colorname.Form("%s+%d",name,n-10);
1196  else if (n<10) colorname.Form("%s-%d",name,10-n);
1197  else colorname.Form("%s",name);
1198  color->SetName(colorname);
1199  }
1200  }
1201 }
1202 
1203 ////////////////////////////////////////////////////////////////////////////////
1204 /// Create the "rectangular" colors in the color wheel.
1205 
1206 void TColor::CreateColorsRectangle(Int_t offset, const char *name, UChar_t *rgb)
1208  TString colorname;
1209  for (Int_t n=0;n<20;n++) {
1210  Int_t colorn = offset+n-9;
1211  TColor *color = gROOT->GetColor(colorn);
1212  if (!color) {
1213  color = new TColor(colorn,rgb[3*n]/255.,rgb[3*n+1]/255.,rgb[3*n+2]/255.);
1214  color->SetTitle(color->AsHexString());
1215  if (n>9) colorname.Form("%s+%d",name,n-9);
1216  else if (n<9) colorname.Form("%s-%d",name,9-n);
1217  else colorname.Form("%s",name);
1218  color->SetName(colorname);
1219  }
1220  }
1221 }
1222 
1223 ////////////////////////////////////////////////////////////////////////////////
1224 /// Static function steering the creation of all colors in the color wheel.
1225 
1228  UChar_t magenta[46]= {255,204,255
1229  ,255,153,255, 204,153,204
1230  ,255,102,255, 204,102,204, 153,102,153
1231  ,255, 51,255, 204, 51,204, 153, 51,153, 102, 51,102
1232  ,255, 0,255, 204, 0,204, 153, 0,153, 102, 0,102, 51, 0, 51};
1233 
1234  UChar_t red[46] = {255,204,204
1235  ,255,153,153, 204,153,153
1236  ,255,102,102, 204,102,102, 153,102,102
1237  ,255, 51, 51, 204, 51, 51, 153, 51, 51, 102, 51, 51
1238  ,255, 0, 0, 204, 0, 0, 153, 0, 0, 102, 0, 0, 51, 0, 0};
1239 
1240  UChar_t yellow[46] = {255,255,204
1241  ,255,255,153, 204,204,153
1242  ,255,255,102, 204,204,102, 153,153,102
1243  ,255,255, 51, 204,204, 51, 153,153, 51, 102,102, 51
1244  ,255,255, 0, 204,204, 0, 153,153, 0, 102,102, 0, 51, 51, 0};
1245 
1246  UChar_t green[46] = {204,255,204
1247  ,153,255,153, 153,204,153
1248  ,102,255,102, 102,204,102, 102,153,102
1249  , 51,255, 51, 51,204, 51, 51,153, 51, 51,102, 51
1250  , 0,255, 0, 0,204, 0, 0,153, 0, 0,102, 0, 0, 51, 0};
1251 
1252  UChar_t cyan[46] = {204,255,255
1253  ,153,255,255, 153,204,204
1254  ,102,255,255, 102,204,204, 102,153,153
1255  , 51,255,255, 51,204,204, 51,153,153, 51,102,102
1256  , 0,255,255, 0,204,204, 0,153,153, 0,102,102, 0, 51, 51};
1257 
1258  UChar_t blue[46] = {204,204,255
1259  ,153,153,255, 153,153,204
1260  ,102,102,255, 102,102,204, 102,102,153
1261  , 51, 51,255, 51, 51,204, 51, 51,153, 51, 51,102
1262  , 0, 0,255, 0, 0,204, 0, 0,153, 0, 0,102, 0, 0, 51};
1263 
1264  UChar_t pink[60] = {255, 51,153, 204, 0,102, 102, 0, 51, 153, 0, 51, 204, 51,102
1265  ,255,102,153, 255, 0,102, 255, 51,102, 204, 0, 51, 255, 0, 51
1266  ,255,153,204, 204,102,153, 153, 51,102, 153, 0,102, 204, 51,153
1267  ,255,102,204, 255, 0,153, 204, 0,153, 255, 51,204, 255, 0,153};
1268 
1269  UChar_t orange[60]={255,204,153, 204,153,102, 153,102, 51, 153,102, 0, 204,153, 51
1270  ,255,204,102, 255,153, 0, 255,204, 51, 204,153, 0, 255,204, 0
1271  ,255,153, 51, 204,102, 0, 102, 51, 0, 153, 51, 0, 204,102, 51
1272  ,255,153,102, 255,102, 0, 255,102, 51, 204, 51, 0, 255, 51, 0};
1273 
1274  UChar_t spring[60]={153,255, 51, 102,204, 0, 51,102, 0, 51,153, 0, 102,204, 51
1275  ,153,255,102, 102,255, 0, 102,255, 51, 51,204, 0, 51,255, 0
1276  ,204,255,153, 153,204,102, 102,153, 51, 102,153, 0, 153,204, 51
1277  ,204,255,102, 153,255, 0, 204,255, 51, 153,204, 0, 204,255, 0};
1278 
1279  UChar_t teal[60] = {153,255,204, 102,204,153, 51,153,102, 0,153,102, 51,204,153
1280  ,102,255,204, 0,255,102, 51,255,204, 0,204,153, 0,255,204
1281  , 51,255,153, 0,204,102, 0,102, 51, 0,153, 51, 51,204,102
1282  ,102,255,153, 0,255,153, 51,255,102, 0,204, 51, 0,255, 51};
1283 
1284  UChar_t azure[60] ={153,204,255, 102,153,204, 51,102,153, 0, 51,153, 51,102,204
1285  ,102,153,255, 0,102,255, 51,102,255, 0, 51,204, 0, 51,255
1286  , 51,153,255, 0,102,204, 0, 51,102, 0,102,153, 51,153,204
1287  ,102,204,255, 0,153,255, 51,204,255, 0,153,204, 0,204,255};
1288 
1289  UChar_t violet[60]={204,153,255, 153,102,204, 102, 51,153, 102, 0,153, 153, 51,204
1290  ,204,102,255, 153, 0,255, 204, 51,255, 153, 0,204, 204, 0,255
1291  ,153, 51,255, 102, 0,204, 51, 0,102, 51, 0,153, 102, 51,204
1292  ,153,102,255, 102, 0,255, 102, 51,255, 51, 0,204, 51, 0,255};
1293 
1294  TColor::CreateColorsCircle(kMagenta,"kMagenta",magenta);
1295  TColor::CreateColorsCircle(kRed, "kRed", red);
1296  TColor::CreateColorsCircle(kYellow, "kYellow", yellow);
1297  TColor::CreateColorsCircle(kGreen, "kGreen", green);
1298  TColor::CreateColorsCircle(kCyan, "kCyan", cyan);
1299  TColor::CreateColorsCircle(kBlue, "kBlue", blue);
1300 
1301  TColor::CreateColorsRectangle(kPink, "kPink", pink);
1302  TColor::CreateColorsRectangle(kOrange,"kOrange",orange);
1303  TColor::CreateColorsRectangle(kSpring,"kSpring",spring);
1304  TColor::CreateColorsRectangle(kTeal, "kTeal", teal);
1305  TColor::CreateColorsRectangle(kAzure, "kAzure", azure);
1306  TColor::CreateColorsRectangle(kViolet,"kViolet",violet);
1307 
1309 }
1310 
1311 ////////////////////////////////////////////////////////////////////////////////
1312 /// Static function returning the color number i in current palette.
1313 
1316  Int_t ncolors = fgPalette.fN;
1317  if (ncolors == 0) return 0;
1318  Int_t icol = i%ncolors;
1319  if (icol < 0) icol = 0;
1320  return fgPalette.fArray[icol];
1321 }
1322 
1323 ////////////////////////////////////////////////////////////////////////////////
1324 /// Static function returning number of colors in the color palette.
1325 
1328  return fgPalette.fN;
1329 }
1330 
1331 ////////////////////////////////////////////////////////////////////////////////
1332 /// Return pixel value corresponding to this color. This pixel value can
1333 /// be used in the GUI classes. This call does not work in batch mode since
1334 /// it needs to communicate with the graphics system.
1335 
1336 ULong_t TColor::GetPixel() const
1338  if (gVirtualX && !gROOT->IsBatch()) {
1339  if (gApplication) {
1342  }
1343  return gVirtualX->GetPixel(fNumber);
1344  }
1345 
1346  return 0;
1347 }
1348 
1349 ////////////////////////////////////////////////////////////////////////////////
1350 /// Static method to compute RGB from HLS. The l and s are between [0,1]
1351 /// and h is between [0,360]. The returned r,g,b triplet is between [0,1].
1352 
1353 void TColor::HLS2RGB(Float_t hue, Float_t light, Float_t satur,
1355 {
1356 
1357  Float_t rh, rl, rs, rm1, rm2;
1358  rh = rl = rs = 0;
1359  if (hue > 0) { rh = hue; if (rh > 360) rh = 360; }
1360  if (light > 0) { rl = light; if (rl > 1) rl = 1; }
1361  if (satur > 0) { rs = satur; if (rs > 1) rs = 1; }
1362 
1363  if (rl <= 0.5)
1364  rm2 = rl*(1.0 + rs);
1365  else
1366  rm2 = rl + rs - rl*rs;
1367  rm1 = 2.0*rl - rm2;
1368 
1369  if (!rs) { r = rl; g = rl; b = rl; return; }
1370  r = HLStoRGB1(rm1, rm2, rh+120);
1371  g = HLStoRGB1(rm1, rm2, rh);
1372  b = HLStoRGB1(rm1, rm2, rh-120);
1373 }
1374 
1375 ////////////////////////////////////////////////////////////////////////////////
1376 /// Static method. Auxiliary to HLS2RGB().
1377 
1380  Float_t hue = huei;
1381  if (hue > 360) hue = hue - 360;
1382  if (hue < 0) hue = hue + 360;
1383  if (hue < 60 ) return rn1 + (rn2-rn1)*hue/60;
1384  if (hue < 180) return rn2;
1385  if (hue < 240) return rn1 + (rn2-rn1)*(240-hue)/60;
1386  return rn1;
1387 }
1388 
1389 ////////////////////////////////////////////////////////////////////////////////
1390 /// Static method to compute RGB from HLS. The h,l,s are between [0,255].
1391 /// The returned r,g,b triplet is between [0,255].
1392 
1393 void TColor::HLS2RGB(Int_t h, Int_t l, Int_t s, Int_t &r, Int_t &g, Int_t &b)
1395  Float_t hh, ll, ss, rr, gg, bb;
1396 
1397  hh = Float_t(h) * 360 / 255;
1398  ll = Float_t(l) / 255;
1399  ss = Float_t(s) / 255;
1400 
1401  TColor::HLStoRGB(hh, ll, ss, rr, gg, bb);
1402 
1403  r = (Int_t) (rr * 255);
1404  g = (Int_t) (gg * 255);
1405  b = (Int_t) (bb * 255);
1406 }
1407 
1408 ////////////////////////////////////////////////////////////////////////////////
1409 /// Static method to compute RGB from HSV:
1410 ///
1411 /// - The hue value runs from 0 to 360.
1412 /// - The saturation is the degree of strength or purity and is from 0 to 1.
1413 /// Purity is how much white is added to the color, so S=1 makes the purest
1414 /// color (no white).
1415 /// - Brightness value also ranges from 0 to 1, where 0 is the black.
1416 ///
1417 /// The returned r,g,b triplet is between [0,1].
1418 
1419 void TColor::HSV2RGB(Float_t hue, Float_t satur, Float_t value,
1421 {
1422  Int_t i;
1423  Float_t f, p, q, t;
1424 
1425  if (satur==0) {
1426  // Achromatic (grey)
1427  r = g = b = value;
1428  return;
1429  }
1430 
1431  hue /= 60; // sector 0 to 5
1432  i = (Int_t)floor(hue);
1433  f = hue-i; // factorial part of hue
1434  p = value*(1-satur);
1435  q = value*(1-satur*f );
1436  t = value*(1-satur*(1-f));
1437 
1438  switch (i) {
1439  case 0:
1440  r = value;
1441  g = t;
1442  b = p;
1443  break;
1444  case 1:
1445  r = q;
1446  g = value;
1447  b = p;
1448  break;
1449  case 2:
1450  r = p;
1451  g = value;
1452  b = t;
1453  break;
1454  case 3:
1455  r = p;
1456  g = q;
1457  b = value;
1458  break;
1459  case 4:
1460  r = t;
1461  g = p;
1462  b = value;
1463  break;
1464  default:
1465  r = value;
1466  g = p;
1467  b = q;
1468  break;
1469  }
1470 }
1471 
1472 ////////////////////////////////////////////////////////////////////////////////
1473 /// List this color with its attributes.
1474 
1475 void TColor::ls(Option_t *) const
1477  printf("Color:%d Red=%f Green=%f Blue=%f Alpha=%f Name=%s\n",
1479 }
1480 
1481 ////////////////////////////////////////////////////////////////////////////////
1482 /// Dump this color with its attributes.
1483 
1484 void TColor::Print(Option_t *) const
1486  ls();
1487 }
1488 
1489 ////////////////////////////////////////////////////////////////////////////////
1490 /// Static method to compute HLS from RGB. The r,g,b triplet is between
1491 /// [0,1], hue is between [0,360], light and satur are [0,1].
1492 
1493 void TColor::RGB2HLS(Float_t rr, Float_t gg, Float_t bb,
1494  Float_t &hue, Float_t &light, Float_t &satur)
1495 {
1496  Float_t rnorm, gnorm, bnorm, minval, maxval, msum, mdiff, r, g, b;
1497  minval = maxval =0 ;
1498  r = g = b = 0;
1499  if (rr > 0) { r = rr; if (r > 1) r = 1; }
1500  if (gg > 0) { g = gg; if (g > 1) g = 1; }
1501  if (bb > 0) { b = bb; if (b > 1) b = 1; }
1502 
1503  minval = r;
1504  if (g < minval) minval = g;
1505  if (b < minval) minval = b;
1506  maxval = r;
1507  if (g > maxval) maxval = g;
1508  if (b > maxval) maxval = b;
1509 
1510  rnorm = gnorm = bnorm = 0;
1511  mdiff = maxval - minval;
1512  msum = maxval + minval;
1513  light = 0.5 * msum;
1514  if (maxval != minval) {
1515  rnorm = (maxval - r)/mdiff;
1516  gnorm = (maxval - g)/mdiff;
1517  bnorm = (maxval - b)/mdiff;
1518  } else {
1519  satur = hue = 0;
1520  return;
1521  }
1522 
1523  if (light < 0.5)
1524  satur = mdiff/msum;
1525  else
1526  satur = mdiff/(2.0 - msum);
1527 
1528  if (r == maxval)
1529  hue = 60.0 * (6.0 + bnorm - gnorm);
1530  else if (g == maxval)
1531  hue = 60.0 * (2.0 + rnorm - bnorm);
1532  else
1533  hue = 60.0 * (4.0 + gnorm - rnorm);
1534 
1535  if (hue > 360)
1536  hue = hue - 360;
1537 }
1538 
1539 ////////////////////////////////////////////////////////////////////////////////
1540 /// Static method to compute HSV from RGB.
1541 ///
1542 /// - The input values:
1543 /// - r,g,b triplet is between [0,1].
1544 /// - The returned values:
1545 /// - The hue value runs from 0 to 360.
1546 /// - The saturation is the degree of strength or purity and is from 0 to 1.
1547 /// Purity is how much white is added to the color, so S=1 makes the purest
1548 /// color (no white).
1549 /// - Brightness value also ranges from 0 to 1, where 0 is the black.
1550 
1552  Float_t &hue, Float_t &satur, Float_t &value)
1553 {
1554  Float_t min, max, delta;
1555 
1556  min = TMath::Min(TMath::Min(r, g), b);
1557  max = TMath::Max(TMath::Max(r, g), b);
1558  value = max;
1559 
1560  delta = max - min;
1561 
1562  if (max != 0) {
1563  satur = delta/max;
1564  } else {
1565  satur = 0;
1566  hue = -1;
1567  return;
1568  }
1569 
1570  if (r == max) {
1571  hue = (g-b)/delta;
1572  } else if (g == max) {
1573  hue = 2+(b-r)/delta;
1574  } else {
1575  hue = 4+(r-g)/delta;
1576  }
1577 
1578  hue *= 60;
1579  if (hue < 0) hue += 360;
1580 }
1581 
1582 ////////////////////////////////////////////////////////////////////////////////
1583 /// Static method to compute HLS from RGB. The r,g,b triplet is between
1584 /// [0,255], hue, light and satur are between [0,255].
1585 
1586 void TColor::RGB2HLS(Int_t r, Int_t g, Int_t b, Int_t &h, Int_t &l, Int_t &s)
1588  Float_t rr, gg, bb, hue, light, satur;
1589 
1590  rr = Float_t(r) / 255;
1591  gg = Float_t(g) / 255;
1592  bb = Float_t(b) / 255;
1593 
1594  TColor::RGBtoHLS(rr, gg, bb, hue, light, satur);
1595 
1596  h = (Int_t) (hue/360 * 255);
1597  l = (Int_t) (light * 255);
1598  s = (Int_t) (satur * 255);
1599 }
1600 
1601 ////////////////////////////////////////////////////////////////////////////////
1602 /// Initialize this color and its associated colors.
1603 
1607  fRed = r;
1608  fGreen = g;
1609  fBlue = b;
1610 
1611  if (fRed < 0) return;
1612 
1613  RGBtoHLS(r, g, b, fHue, fLight, fSaturation);
1614 
1615  Int_t nplanes = 16;
1616  if (gVirtualX) gVirtualX->GetPlanes(nplanes);
1617  if (nplanes == 0) nplanes = 16;
1618 
1619  // allocate color now (can be delayed when we have a large colormap)
1620 #ifndef R__WIN32
1621  if (nplanes < 15)
1622 #endif
1623  Allocate();
1624 
1625  if (fNumber > 50) return;
1626 
1627  // now define associated colors for WBOX shading
1628  Float_t dr, dg, db, lr, lg, lb;
1629 
1630  // set dark color
1631  HLStoRGB(fHue, 0.7*fLight, fSaturation, dr, dg, db);
1632  TColor *dark = gROOT->GetColor(100+fNumber);
1633  if (dark) {
1634  if (nplanes > 8) dark->SetRGB(dr, dg, db);
1635  else dark->SetRGB(0.3,0.3,0.3);
1636  }
1637 
1638  // set light color
1639  HLStoRGB(fHue, 1.2*fLight, fSaturation, lr, lg, lb);
1640  TColor *light = gROOT->GetColor(150+fNumber);
1641  if (light) {
1642  if (nplanes > 8) light->SetRGB(lr, lg, lb);
1643  else light->SetRGB(0.8,0.8,0.8);
1644  }
1645 }
1646 
1647 ////////////////////////////////////////////////////////////////////////////////
1648 /// Make this color known to the graphics system.
1649 
1650 void TColor::Allocate()
1652  if (gVirtualX && !gROOT->IsBatch())
1653 
1654  gVirtualX->SetRGB(fNumber, GetRed(), GetGreen(), GetBlue());
1655 }
1656 
1657 ////////////////////////////////////////////////////////////////////////////////
1658 /// Static method returning color number for color specified by
1659 /// hex color string of form: "#rrggbb", where rr, gg and bb are in
1660 /// hex between [0,FF], e.g. "#c0c0c0".
1661 ///
1662 /// If specified color does not exist it will be created with as
1663 /// name "#rrggbb" with rr, gg and bb in hex between [0,FF].
1664 
1665 Int_t TColor::GetColor(const char *hexcolor)
1667  if (hexcolor && *hexcolor == '#') {
1668  Int_t r, g, b;
1669  if (sscanf(hexcolor+1, "%02x%02x%02x", &r, &g, &b) == 3)
1670  return GetColor(r, g, b);
1671  }
1672  ::Error("TColor::GetColor(const char*)", "incorrect color string");
1673  return 0;
1674 }
1675 
1676 ////////////////////////////////////////////////////////////////////////////////
1677 /// Static method returning color number for color specified by
1678 /// r, g and b. The r,g,b should be in the range [0,1].
1679 ///
1680 /// If specified color does not exist it will be created
1681 /// with as name "#rrggbb" with rr, gg and bb in hex between
1682 /// [0,FF].
1683 
1686  Int_t rr, gg, bb;
1687  rr = Int_t(r * 255);
1688  gg = Int_t(g * 255);
1689  bb = Int_t(b * 255);
1690 
1691  return GetColor(rr, gg, bb);
1692 }
1693 
1694 ////////////////////////////////////////////////////////////////////////////////
1695 /// Static method returning color number for color specified by
1696 /// system dependent pixel value. Pixel values can be obtained, e.g.,
1697 /// from the GUI color picker.
1698 
1701  Int_t r, g, b;
1702 
1703  Pixel2RGB(pixel, r, g, b);
1704 
1705  return GetColor(r, g, b);
1706 }
1707 
1708 ////////////////////////////////////////////////////////////////////////////////
1709 /// Static method returning color number for color specified by
1710 /// r, g and b. The r,g,b should be in the range [0,255].
1711 /// If the specified color does not exist it will be created
1712 /// with as name "#rrggbb" with rr, gg and bb in hex between
1713 /// [0,FF].
1714 
1718  if (r < 0) r = 0;
1719  if (g < 0) g = 0;
1720  if (b < 0) b = 0;
1721  if (r > 255) r = 255;
1722  if (g > 255) g = 255;
1723  if (b > 255) b = 255;
1724 
1725  // Get list of all defined colors
1726  TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
1727 
1728  TColor *color = 0;
1729 
1730  // Look for color by name
1731  if ((color = (TColor*)colors->FindObject(Form("#%02x%02x%02x", r, g, b))))
1732  // We found the color by name, so we use that right away
1733  return color->GetNumber();
1734 
1735  Float_t rr, gg, bb;
1736  rr = Float_t(r)/255.;
1737  gg = Float_t(g)/255.;
1738  bb = Float_t(b)/255.;
1739 
1740  TIter next(colors);
1741 
1742  Int_t nplanes = 16;
1743  Float_t thres = 1.0/31.0; // 5 bits per color : 0 - 0x1F !
1744  if (gVirtualX) gVirtualX->GetPlanes(nplanes);
1745  if (nplanes >= 24)
1746  thres = 1.0/255.0; // 8 bits per color : 0 - 0xFF !
1747 
1748  // Loop over all defined colors
1749  while ((color = (TColor*)next())) {
1750  if (TMath::Abs(color->GetRed() - rr) > thres)
1751  continue;
1752  if (TMath::Abs(color->GetGreen() - gg) > thres)
1753  continue;
1754  if (TMath::Abs(color->GetBlue() - bb) > thres)
1755  continue;
1756 
1757  // We found a matching color in the color table
1758  return color->GetNumber();
1759  }
1760 
1761  // We didn't find a matching color in the color table, so we
1762  // add it. Note name is of the form "#rrggbb" where rr, etc. are
1763  // hexadecimal numbers.
1764  color = new TColor(colors->GetLast()+1, rr, gg, bb,
1765  Form("#%02x%02x%02x", r, g, b));
1766 
1767  return color->GetNumber();
1768 }
1769 
1770 ////////////////////////////////////////////////////////////////////////////////
1771 /// Static function: Returns the bright color number corresponding to n
1772 /// If the TColor object does not exist, it is created.
1773 /// The convention is that the bright color nb = n+150
1774 
1777  if (n < 0) return -1;
1778 
1779  // Get list of all defined colors
1780  TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
1781  Int_t ncolors = colors->GetSize();
1782  // Get existing color at index n
1783  TColor *color = 0;
1784  if (n < ncolors) color = (TColor*)colors->At(n);
1785  if (!color) return -1;
1786 
1787  //Get the rgb of the the new bright color corresponding to color n
1788  Float_t r,g,b;
1789  HLStoRGB(color->GetHue(), 1.2*color->GetLight(), color->GetSaturation(), r, g, b);
1790 
1791  //Build the bright color (unless the slot nb is already used)
1792  Int_t nb = n+150;
1793  TColor *colorb = 0;
1794  if (nb < ncolors) colorb = (TColor*)colors->At(nb);
1795  if (colorb) return nb;
1796  colorb = new TColor(nb,r,g,b);
1797  colorb->SetName(Form("%s_bright",color->GetName()));
1798  colors->AddAtAndExpand(colorb,nb);
1799  return nb;
1800 }
1801 
1802 ////////////////////////////////////////////////////////////////////////////////
1803 /// Static function: Returns the dark color number corresponding to n
1804 /// If the TColor object does not exist, it is created.
1805 /// The convention is that the dark color nd = n+100
1806 
1809  if (n < 0) return -1;
1810 
1811  // Get list of all defined colors
1812  TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
1813  Int_t ncolors = colors->GetSize();
1814  // Get existing color at index n
1815  TColor *color = 0;
1816  if (n < ncolors) color = (TColor*)colors->At(n);
1817  if (!color) return -1;
1818 
1819  //Get the rgb of the the new dark color corresponding to color n
1820  Float_t r,g,b;
1821  HLStoRGB(color->GetHue(), 0.7*color->GetLight(), color->GetSaturation(), r, g, b);
1822 
1823  //Build the dark color (unless the slot nd is already used)
1824  Int_t nd = n+100;
1825  TColor *colord = 0;
1826  if (nd < ncolors) colord = (TColor*)colors->At(nd);
1827  if (colord) return nd;
1828  colord = new TColor(nd,r,g,b);
1829  colord->SetName(Form("%s_dark",color->GetName()));
1830  colors->AddAtAndExpand(colord,nd);
1831  return nd;
1832 }
1833 
1834 ////////////////////////////////////////////////////////////////////////////////
1835 /// Static function: Returns the transparent color number corresponding to n.
1836 /// The transparency level is given by the alpha value a.
1837 
1840  if (n < 0) return -1;
1841 
1842  TColor *color = gROOT->GetColor(n);
1843  if (color) {
1844  TColor *colort = new TColor(gROOT->GetListOfColors()->GetLast()+1,
1845  color->GetRed(), color->GetGreen(), color->GetBlue());
1846  colort->SetAlpha(a);
1847  colort->SetName(Form("%s_transparent",color->GetName()));
1848  return colort->GetNumber();
1849  } else {
1850  ::Error("TColor::GetColorTransparent", "color with index %d not defined", n);
1851  return -1;
1852  }
1853 }
1854 
1855 ////////////////////////////////////////////////////////////////////////////////
1856 /// Static method that given a color index number, returns the corresponding
1857 /// pixel value. This pixel value can be used in the GUI classes. This call
1858 /// does not work in batch mode since it needs to communicate with the
1859 /// graphics system.
1860 
1864  TColor *color = gROOT->GetColor(ci);
1865  if (color)
1866  return color->GetPixel();
1867  else
1868  ::Warning("TColor::Number2Pixel", "color with index %d not defined", ci);
1869 
1870  return 0;
1871 }
1872 
1873 ////////////////////////////////////////////////////////////////////////////////
1874 /// Convert r,g,b to graphics system dependent pixel value.
1875 /// The r,g,b triplet must be [0,1].
1876 
1879  if (r < 0) r = 0;
1880  if (g < 0) g = 0;
1881  if (b < 0) b = 0;
1882  if (r > 1) r = 1;
1883  if (g > 1) g = 1;
1884  if (b > 1) b = 1;
1885 
1886  ColorStruct_t color;
1887  color.fRed = UShort_t(r * 65535);
1888  color.fGreen = UShort_t(g * 65535);
1889  color.fBlue = UShort_t(b * 65535);
1890  color.fMask = kDoRed | kDoGreen | kDoBlue;
1891  gVirtualX->AllocColor(gVirtualX->GetColormap(), color);
1892  return color.fPixel;
1893 }
1894 
1895 ////////////////////////////////////////////////////////////////////////////////
1896 /// Convert r,g,b to graphics system dependent pixel value.
1897 /// The r,g,b triplet must be [0,255].
1898 
1901  if (r < 0) r = 0;
1902  if (g < 0) g = 0;
1903  if (b < 0) b = 0;
1904  if (r > 255) r = 255;
1905  if (g > 255) g = 255;
1906  if (b > 255) b = 255;
1907 
1908  ColorStruct_t color;
1909  color.fRed = UShort_t(r * 257); // 65535/255
1910  color.fGreen = UShort_t(g * 257);
1911  color.fBlue = UShort_t(b * 257);
1912  color.fMask = kDoRed | kDoGreen | kDoBlue;
1913  gVirtualX->AllocColor(gVirtualX->GetColormap(), color);
1914  return color.fPixel;
1915 }
1916 
1917 ////////////////////////////////////////////////////////////////////////////////
1918 /// Convert machine dependent pixel value (obtained via RGB2Pixel or
1919 /// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet.
1920 /// The r,g,b triplet will be [0,1].
1921 
1922 void TColor::Pixel2RGB(ULong_t pixel, Float_t &r, Float_t &g, Float_t &b)
1924  ColorStruct_t color;
1925  color.fPixel = pixel;
1926  gVirtualX->QueryColor(gVirtualX->GetColormap(), color);
1927  r = (Float_t)color.fRed / 65535;
1928  g = (Float_t)color.fGreen / 65535;
1929  b = (Float_t)color.fBlue / 65535;
1930 }
1931 
1932 ////////////////////////////////////////////////////////////////////////////////
1933 /// Convert machine dependent pixel value (obtained via RGB2Pixel or
1934 /// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet.
1935 /// The r,g,b triplet will be [0,255].
1936 
1937 void TColor::Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b)
1939  ColorStruct_t color;
1940  color.fPixel = pixel;
1941  gVirtualX->QueryColor(gVirtualX->GetColormap(), color);
1942  r = color.fRed / 257;
1943  g = color.fGreen / 257;
1944  b = color.fBlue / 257;
1945 }
1946 
1947 ////////////////////////////////////////////////////////////////////////////////
1948 /// Convert machine dependent pixel value (obtained via RGB2Pixel or
1949 /// via Number2Pixel() or via TColor::GetPixel()) to a hexadecimal string.
1950 /// This string can be directly passed to, for example,
1951 /// TGClient::GetColorByName(). String will be reused so copy immediately
1952 /// if needed.
1953 
1954 const char *TColor::PixelAsHexString(ULong_t pixel)
1956  static TString tempbuf;
1957  Int_t r, g, b;
1958  Pixel2RGB(pixel, r, g, b);
1959  tempbuf.Form("#%02x%02x%02x", r, g, b);
1960  return tempbuf;
1961 }
1962 
1963 ////////////////////////////////////////////////////////////////////////////////
1964 /// Save a color with index > 228 as a C++ statement(s) on output stream out.
1965 
1966 void TColor::SaveColor(std::ostream &out, Int_t ci)
1968  char quote = '"';
1969  Float_t r,g,b,a;
1970  Int_t ri, gi, bi;
1971  TString cname;
1972 
1973  TColor *c = gROOT->GetColor(ci);
1974  if (c) {
1975  c->GetRGB(r, g, b);
1976  a = c->GetAlpha();
1977  } else {
1978  return;
1979  }
1980 
1981  if (gROOT->ClassSaved(TColor::Class())) {
1982  out << std::endl;
1983  } else {
1984  out << std::endl;
1985  out << " Int_t ci; // for color index setting" << std::endl;
1986  out << " TColor *color; // for color definition with alpha" << std::endl;
1987  }
1988 
1989  if (a<1) {
1990  out<<" ci = "<<ci<<";"<<std::endl;
1991  out<<" color = new TColor(ci, "<<r<<", "<<g<<", "<<b<<", "
1992  <<"\" \", "<<a<<");"<<std::endl;
1993  } else {
1994  ri = (Int_t)(255*r);
1995  gi = (Int_t)(255*g);
1996  bi = (Int_t)(255*b);
1997  cname.Form("#%02x%02x%02x", ri, gi, bi);
1998  out<<" ci = TColor::GetColor("<<quote<<cname.Data()<<quote<<");"<<std::endl;
1999  }
2000 }
2001 
2002 ////////////////////////////////////////////////////////////////////////////////
2003 /// Return whether all colors return grayscale values.
2006  return fgGrayscaleMode;
2007 }
2008 
2009 ////////////////////////////////////////////////////////////////////////////////
2010 /// Set whether all colors should return grayscale values.
2011 
2012 void TColor::SetGrayscale(Bool_t set /*= kTRUE*/)
2014  if (fgGrayscaleMode == set) return;
2015 
2016  fgGrayscaleMode = set;
2017 
2018  if (!gVirtualX || gROOT->IsBatch()) return;
2019 
2021  TIter iColor(gROOT->GetListOfColors());
2022  TColor* color = 0;
2023  while ((color = (TColor*) iColor()))
2024  color->Allocate();
2025 }
2026 
2027 ////////////////////////////////////////////////////////////////////////////////
2028 /// Static function creating a color table with several connected linear gradients.
2029 ///
2030 /// - Number: The number of end point colors that will form the gradients.
2031 /// Must be at least 2.
2032 /// - Stops: Where in the whole table the end point colors should lie.
2033 /// Each entry must be on [0, 1], each entry must be greater than
2034 /// the previous entry.
2035 /// - Red, Green, Blue: The end point color values.
2036 /// Each entry must be on [0, 1]
2037 /// - NColors: Total number of colors in the table. Must be at least 1.
2038 ///
2039 /// Returns a positive value on success and -1 on error.
2040 ///
2041 /// The table is constructed by tracing lines between the given points in
2042 /// RGB space. Each color value may have a value between 0 and 1. The
2043 /// difference between consecutive "Stops" values gives the fraction of
2044 /// space in the whole table that should be used for the interval between
2045 /// the corresponding color values.
2046 ///
2047 /// Normally the first element of Stops should be 0 and the last should be 1.
2048 /// If this is not true, fewer than NColors will be used in proportion with
2049 /// the total interval between the first and last elements of Stops.
2050 ///
2051 /// This definition is similar to the povray-definition of gradient
2052 /// color tables.
2053 ///
2054 /// For instance:
2055 /// ~~~ {.cpp}
2056 /// UInt_t Number = 3;
2057 /// Double_t Red[3] = { 0.0, 1.0, 1.0 };
2058 /// Double_t Green[3] = { 0.0, 0.0, 1.0 };
2059 /// Double_t Blue[3] = { 1.0, 0.0, 1.0 };
2060 /// Double_t Stops[3] = { 0.0, 0.4, 1.0 };
2061 /// ~~~
2062 /// This defines a table in which there are three color end points:
2063 /// RGB = {0, 0, 1}, {1, 0, 0}, and {1, 1, 1} = blue, red, white
2064 /// The first 40% of the table is used to go linearly from blue to red.
2065 /// The remaining 60% of the table is used to go linearly from red to white.
2066 ///
2067 /// If you define a very short interval such that less than one color fits
2068 /// in it, no colors at all will be allocated. If this occurs for all
2069 /// intervals, ROOT will revert to the default palette.
2070 ///
2071 /// Original code by Andreas Zoglauer (zog@mpe.mpg.de)
2072 
2074  Double_t* Red, Double_t* Green,
2075  Double_t* Blue, UInt_t NColors, Float_t alpha)
2076 {
2078 
2079  UInt_t g, c;
2080  UInt_t nPalette = 0;
2081  Int_t *palette = new Int_t[NColors+1];
2082  UInt_t nColorsGradient;
2083 
2084  if(Number < 2 || NColors < 1){
2085  delete [] palette;
2086  return -1;
2087  }
2088 
2089  // Check if all RGB values are between 0.0 and 1.0 and
2090  // Stops goes from 0.0 to 1.0 in increasing order.
2091  for (c = 0; c < Number; c++) {
2092  if (Red[c] < 0 || Red[c] > 1.0 ||
2093  Green[c] < 0 || Green[c] > 1.0 ||
2094  Blue[c] < 0 || Blue[c] > 1.0 ||
2095  Stops[c] < 0 || Stops[c] > 1.0) {
2096  delete [] palette;
2097  return -1;
2098  }
2099  if (c >= 1) {
2100  if (Stops[c-1] > Stops[c]) {
2101  delete [] palette;
2102  return -1;
2103  }
2104  }
2105  }
2106 
2107  // Now create the colors and add them to the default palette:
2108 
2109  // For each defined gradient...
2110  for (g = 1; g < Number; g++) {
2111  // create the colors...
2112  nColorsGradient = (Int_t) (floor(NColors*Stops[g]) - floor(NColors*Stops[g-1]));
2113  for (c = 0; c < nColorsGradient; c++) {
2114  new TColor( Float_t(Red[g-1] + c * (Red[g] - Red[g-1]) / nColorsGradient),
2115  Float_t(Green[g-1] + c * (Green[g] - Green[g-1])/ nColorsGradient),
2116  Float_t(Blue[g-1] + c * (Blue[g] - Blue[g-1]) / nColorsGradient),
2117  alpha);
2118  palette[nPalette] = gHighestColorIndex;
2119  nPalette++;
2120  }
2121  }
2122 
2123  TColor::SetPalette(nPalette, palette);
2124  delete [] palette;
2125  return gHighestColorIndex + 1 - NColors;
2126 }
2127 
2128 
2129 ////////////////////////////////////////////////////////////////////////////////
2130 /// Static function.
2131 /// The color palette is used by the histogram classes
2132 /// (see TH1::Draw options).
2133 /// For example TH1::Draw("col") draws a 2-D histogram with cells
2134 /// represented by a box filled with a color CI function of the cell content.
2135 /// if the cell content is N, the color CI used will be the color number
2136 /// in colors[N],etc. If the maximum cell content is > ncolors, all
2137 /// cell contents are scaled to ncolors.
2138 ///
2139 /// `if ncolors <= 0` a default palette (see below) of 50 colors is
2140 /// defined. The colors defined in this palette are OK for coloring pads, labels.
2141 ///
2142 /// ~~~ {.cpp}
2143 /// index 0->9 : grey colors from light to dark grey
2144 /// index 10->19 : "brown" colors
2145 /// index 20->29 : "blueish" colors
2146 /// index 30->39 : "redish" colors
2147 /// index 40->49 : basic colors
2148 /// ~~~
2149 ///
2150 /// `if ncolors == 1 && colors == 0`, a Rainbow Color map is created
2151 /// with 50 colors. It is kept for backward compatibility. Better palettes like
2152 /// kBird are recommended.
2153 ///
2154 /// High quality predefined palettes with 255 colors are available when `colors == 0`.
2155 /// The following value of `ncolors` give access to:
2156 ///
2157 /// ~~~ {.cpp}
2158 /// if ncolors = 51 and colors=0, a Deep Sea palette is used.
2159 /// if ncolors = 52 and colors=0, a Grey Scale palette is used.
2160 /// if ncolors = 53 and colors=0, a Dark Body Radiator palette is used.
2161 /// if ncolors = 54 and colors=0, a Two-Color Hue palette is used.(dark blue through neutral gray to bright yellow)
2162 /// if ncolors = 55 and colors=0, a Rain Bow palette is used.
2163 /// if ncolors = 56 and colors=0, an Inverted Dark Body Radiator palette is used.
2164 /// if ncolors = 57 and colors=0, a monotonically increasing L value palette is used.
2165 /// if ncolors = 58 and colors=0, a Cubehelix palette is used
2166 /// (Cf. Dave Green's "cubehelix" colour scheme at http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/)
2167 /// if ncolors = 59 and colors=0, a Green Red Violet palette is used.
2168 /// if ncolors = 60 and colors=0, a Blue Red Yellow palette is used.
2169 /// if ncolors = 61 and colors=0, an Ocean palette is used.
2170 /// if ncolors = 62 and colors=0, a Color Printable On Grey palette is used.
2171 /// if ncolors = 63 and colors=0, an Alpine palette is used.
2172 /// if ncolors = 64 and colors=0, an Aquamarine palette is used.
2173 /// if ncolors = 65 and colors=0, an Army palette is used.
2174 /// if ncolors = 66 and colors=0, an Atlantic palette is used.
2175 /// if ncolors = 67 and colors=0, an Aurora palette is used.
2176 /// if ncolors = 68 and colors=0, an Avocado palette is used.
2177 /// if ncolors = 69 and colors=0, a Beach palette is used.
2178 /// if ncolors = 70 and colors=0, a Black Body palette is used.
2179 /// if ncolors = 71 and colors=0, a Blue Green Yellow palette is used.
2180 /// if ncolors = 72 and colors=0, a Brown Cyan palette is used.
2181 /// if ncolors = 73 and colors=0, a CMYK palette is used.
2182 /// if ncolors = 74 and colors=0, a Candy palette is used.
2183 /// if ncolors = 75 and colors=0, a Cherry palette is used.
2184 /// if ncolors = 76 and colors=0, a Coffee palette is used.
2185 /// if ncolors = 77 and colors=0, a Dark Rain Bow palette is used.
2186 /// if ncolors = 78 and colors=0, a Dark Terrain palette is used.
2187 /// if ncolors = 79 and colors=0, a Fall palette is used.
2188 /// if ncolors = 80 and colors=0, a Fruit Punch palette is used.
2189 /// if ncolors = 81 and colors=0, a Fuchsia palette is used.
2190 /// if ncolors = 82 and colors=0, a Grey Yellow palette is used.
2191 /// if ncolors = 83 and colors=0, a Green Brown Terrain palette is used.
2192 /// if ncolors = 84 and colors=0, a Green Pink palette is used.
2193 /// if ncolors = 85 and colors=0, an Island palette is used.
2194 /// if ncolors = 86 and colors=0, a Lake palette is used.
2195 /// if ncolors = 87 and colors=0, a Light Temperature palette is used.
2196 /// if ncolors = 88 and colors=0, a Light Terrain palette is used.
2197 /// if ncolors = 89 and colors=0, a Mint palette is used.
2198 /// if ncolors = 90 and colors=0, a Neon palette is used.
2199 /// if ncolors = 91 and colors=0, a Pastel palette is used.
2200 /// if ncolors = 92 and colors=0, a Pearl palette is used.
2201 /// if ncolors = 93 and colors=0, a Pigeon palette is used.
2202 /// if ncolors = 94 and colors=0, a Plum palette is used.
2203 /// if ncolors = 95 and colors=0, a Red Blue palette is used.
2204 /// if ncolors = 96 and colors=0, a Rose palette is used.
2205 /// if ncolors = 97 and colors=0, a Rust palette is used.
2206 /// if ncolors = 98 and colors=0, a Sandy Terrain palette is used.
2207 /// if ncolors = 99 and colors=0, a Sienna palette is used.
2208 /// if ncolors = 100 and colors=0, a Solar palette is used.
2209 /// if ncolors = 101 and colors=0, a South West palette is used.
2210 /// if ncolors = 102 and colors=0, a Starry Night palette is used.
2211 /// if ncolors = 103 and colors=0, a Sunset palette is used.
2212 /// if ncolors = 104 and colors=0, a Temperature Map palette is used.
2213 /// if ncolors = 105 and colors=0, a Thermometer palette is used.
2214 /// if ncolors = 106 and colors=0, a Valentine palette is used.
2215 /// if ncolors = 107 and colors=0, a Visible Spectrum palette is used.
2216 /// if ncolors = 108 and colors=0, a Water Melon palette is used.
2217 /// if ncolors = 109 and colors=0, a Cool palette is used.
2218 /// if ncolors = 110 and colors=0, a Copper palette is used.
2219 /// if ncolors = 111 and colors=0, a Gist Earth palette is used.
2220 /// if ncolors = 112 and colors=0, a Viridis palette is used.
2221 /// ~~~
2222 /// These palettes can also be accessed by names:
2223 /// ~~~ {.cpp}
2224 /// kDeepSea=51, kGreyScale=52, kDarkBodyRadiator=53,
2225 /// kBlueYellow= 54, kRainBow=55, kInvertedDarkBodyRadiator=56,
2226 /// kBird=57, kCubehelix=58, kGreenRedViolet=59,
2227 /// kBlueRedYellow=60, kOcean=61, kColorPrintableOnGrey=62,
2228 /// kAlpine=63, kAquamarine=64, kArmy=65,
2229 /// kAtlantic=66, kAurora=67, kAvocado=68,
2230 /// kBeach=69, kBlackBody=70, kBlueGreenYellow=71,
2231 /// kBrownCyan=72, kCMYK=73, kCandy=74,
2232 /// kCherry=75, kCoffee=76, kDarkRainBow=77,
2233 /// kDarkTerrain=78, kFall=79, kFruitPunch=80,
2234 /// kFuchsia=81, kGreyYellow=82, kGreenBrownTerrain=83,
2235 /// kGreenPink=84, kIsland=85, kLake=86,
2236 /// kLightTemperature=87, kLightTerrain=88, kMint=89,
2237 /// kNeon=90, kPastel=91, kPearl=92,
2238 /// kPigeon=93, kPlum=94, kRedBlue=95,
2239 /// kRose=96, kRust=97, kSandyTerrain=98,
2240 /// kSienna=99, kSolar=100, kSouthWest=101,
2241 /// kStarryNight=102, kSunset=103, kTemperatureMap=104,
2242 /// kThermometer=105, kValentine=106, kVisibleSpectrum=107,
2243 /// kWaterMelon=108, kCool=109, kCopper=110,
2244 /// kGistEarth=111 kViridis=112
2245 /// ~~~
2246 /// For example:
2247 /// ~~~ {.cpp}
2248 /// gStyle->SetPalette(kBird);
2249 /// ~~~
2250 /// Set the current palette as "Bird" (number 57).
2251 ///
2252 /// The color numbers specified in the palette can be viewed by selecting
2253 /// the item "colors" in the "VIEW" menu of the canvas toolbar.
2254 /// The color parameters can be changed via TColor::SetRGB.
2255 ///
2256 /// Note that when drawing a 2D histogram `h2` with the option "COL" or
2257 /// "COLZ" or with any "CONT" options using the color map, the number of colors
2258 /// used is defined by the number of contours `n` specified with:
2259 /// `h2->SetContour(n)`
2260 
2261 void TColor::SetPalette(Int_t ncolors, Int_t *colors, Float_t alpha)
2263  Int_t i;
2264 
2265  static Int_t paletteType = 0;
2266 
2267  Int_t palette[50] = {19,18,17,16,15,14,13,12,11,20,
2268  21,22,23,24,25,26,27,28,29,30, 8,
2269  31,32,33,34,35,36,37,38,39,40, 9,
2270  41,42,43,44,45,47,48,49,46,50, 2,
2271  7, 6, 5, 4, 3, 2,1};
2272 
2273  // set default palette (pad type)
2274  if (ncolors <= 0) {
2275  ncolors = 50;
2276  fgPalette.Set(ncolors);
2277  for (i=0;i<ncolors;i++) fgPalette.fArray[i] = palette[i];
2278  paletteType = 1;
2279  return;
2280  }
2281 
2282  // set Rainbow Color map. Kept for backward compatibility.
2283  if (ncolors == 1 && colors == 0) {
2284  ncolors = 50;
2285  fgPalette.Set(ncolors);
2286  for (i=0;i<ncolors;i++) fgPalette.fArray[i] = 51+i;
2287  paletteType = 2;
2288  return;
2289  }
2290 
2291  // High quality palettes (255 levels)
2292  if (colors == 0 && ncolors>50) {
2293 
2294  if (!fgPalettesList.fN) fgPalettesList.Set(62); // Right now 62 high quality palettes
2295  Int_t Idx = (Int_t)fgPalettesList.fArray[ncolors-51]; // High quality palettes indices start at 51
2296 
2297  // This high quality palette has already been created. Reuse it.
2298  if (Idx > 0) {
2299  Double_t alphas = 10*(fgPalettesList.fArray[ncolors-51]-Idx);
2300  Bool_t same_alpha = TMath::Abs(alpha-alphas) < 0.0001;
2301  if (paletteType == ncolors && same_alpha) return; // The current palette is already this one.
2302  fgPalette.Set(255); // High quality palettes have 255 entries
2303  for (i=0;i<255;i++) fgPalette.fArray[i] = Idx+i;
2304  paletteType = ncolors;
2305 
2306  // restore the palette transparency if needed
2307  if (alphas>0 && !same_alpha) {
2308  TColor *ca;
2309  for (i=0;i<255;i++) {
2310  ca = gROOT->GetColor(Idx+i);
2311  ca->SetAlpha(alpha);
2312  }
2313  fgPalettesList.fArray[paletteType-51] = (Double_t)Idx+alpha/10.;
2314  }
2315  return;
2316  }
2317 
2319  Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
2320 
2321  switch (ncolors) {
2322  // Deep Sea
2323  case 51:
2324  {
2325  Double_t red[9] = { 0./255., 9./255., 13./255., 17./255., 24./255., 32./255., 27./255., 25./255., 29./255.};
2326  Double_t green[9] = { 0./255., 0./255., 0./255., 2./255., 37./255., 74./255., 113./255., 160./255., 221./255.};
2327  Double_t blue[9] = { 28./255., 42./255., 59./255., 78./255., 98./255., 129./255., 154./255., 184./255., 221./255.};
2328  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2329  }
2330  break;
2331 
2332  // Grey Scale
2333  case 52:
2334  {
2335  Double_t red[9] = { 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.};
2336  Double_t green[9] = { 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.};
2337  Double_t blue[9] = { 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.};
2338  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2339  }
2340  break;
2341 
2342  // Dark Body Radiator
2343  case 53:
2344  {
2345  Double_t red[9] = { 0./255., 45./255., 99./255., 156./255., 212./255., 230./255., 237./255., 234./255., 242./255.};
2346  Double_t green[9] = { 0./255., 0./255., 0./255., 45./255., 101./255., 168./255., 238./255., 238./255., 243./255.};
2347  Double_t blue[9] = { 0./255., 1./255., 1./255., 3./255., 9./255., 8./255., 11./255., 95./255., 230./255.};
2348  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2349  }
2350  break;
2351 
2352  // Two-color hue (dark blue through neutral gray to bright yellow)
2353  case 54:
2354  {
2355  Double_t red[9] = { 0./255., 22./255., 44./255., 68./255., 93./255., 124./255., 160./255., 192./255., 237./255.};
2356  Double_t green[9] = { 0./255., 16./255., 41./255., 67./255., 93./255., 125./255., 162./255., 194./255., 241./255.};
2357  Double_t blue[9] = { 97./255., 100./255., 99./255., 99./255., 93./255., 68./255., 44./255., 26./255., 74./255.};
2358  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2359  }
2360  break;
2361 
2362  // Rain Bow
2363  case 55:
2364  {
2365  Double_t red[9] = { 0./255., 5./255., 15./255., 35./255., 102./255., 196./255., 208./255., 199./255., 110./255.};
2366  Double_t green[9] = { 0./255., 48./255., 124./255., 192./255., 206./255., 226./255., 97./255., 16./255., 0./255.};
2367  Double_t blue[9] = { 99./255., 142./255., 198./255., 201./255., 90./255., 22./255., 13./255., 8./255., 2./255.};
2368  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2369  }
2370  break;
2371 
2372  // Inverted Dark Body Radiator
2373  case 56:
2374  {
2375  Double_t red[9] = { 242./255., 234./255., 237./255., 230./255., 212./255., 156./255., 99./255., 45./255., 0./255.};
2376  Double_t green[9] = { 243./255., 238./255., 238./255., 168./255., 101./255., 45./255., 0./255., 0./255., 0./255.};
2377  Double_t blue[9] = { 230./255., 95./255., 11./255., 8./255., 9./255., 3./255., 1./255., 1./255., 0./255.};
2378  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2379  }
2380  break;
2381 
2382  // Bird
2383  case 57:
2384  {
2385  Double_t red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764};
2386  Double_t green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832};
2387  Double_t blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539};
2388  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2389  }
2390  break;
2391 
2392  // Cubehelix
2393  case 58:
2394  {
2395  Double_t red[9] = { 0.0000, 0.0956, 0.0098, 0.2124, 0.6905, 0.9242, 0.7914, 0.7596, 1.0000};
2396  Double_t green[9] = { 0.0000, 0.1147, 0.3616, 0.5041, 0.4577, 0.4691, 0.6905, 0.9237, 1.0000};
2397  Double_t blue[9] = { 0.0000, 0.2669, 0.3121, 0.1318, 0.2236, 0.6741, 0.9882, 0.9593, 1.0000};
2398  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2399  }
2400  break;
2401 
2402  // Green Red Violet
2403  case 59:
2404  {
2405  Double_t red[9] = {13./255., 23./255., 25./255., 63./255., 76./255., 104./255., 137./255., 161./255., 206./255.};
2406  Double_t green[9] = {95./255., 67./255., 37./255., 21./255., 0./255., 12./255., 35./255., 52./255., 79./255.};
2407  Double_t blue[9] = { 4./255., 3./255., 2./255., 6./255., 11./255., 22./255., 49./255., 98./255., 208./255.};
2408  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2409  }
2410  break;
2411 
2412  // Blue Red Yellow
2413  case 60:
2414  {
2415  Double_t red[9] = {0./255., 61./255., 89./255., 122./255., 143./255., 160./255., 185./255., 204./255., 231./255.};
2416  Double_t green[9] = {0./255., 0./255., 0./255., 0./255., 14./255., 37./255., 72./255., 132./255., 235./255.};
2417  Double_t blue[9] = {0./255., 140./255., 224./255., 144./255., 4./255., 5./255., 6./255., 9./255., 13./255.};
2418  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2419  }
2420  break;
2421 
2422  // Ocean
2423  case 61:
2424  {
2425  Double_t red[9] = { 14./255., 7./255., 2./255., 0./255., 5./255., 11./255., 55./255., 131./255., 229./255.};
2426  Double_t green[9] = {105./255., 56./255., 26./255., 1./255., 42./255., 74./255., 131./255., 171./255., 229./255.};
2427  Double_t blue[9] = { 2./255., 21./255., 35./255., 60./255., 92./255., 113./255., 160./255., 185./255., 229./255.};
2428  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2429  }
2430  break;
2431 
2432  // Color Printable On Grey
2433  case 62:
2434  {
2435  Double_t red[9] = { 0./255., 0./255., 0./255., 70./255., 148./255., 231./255., 235./255., 237./255., 244./255.};
2436  Double_t green[9] = { 0./255., 0./255., 0./255., 0./255., 0./255., 69./255., 67./255., 216./255., 244./255.};
2437  Double_t blue[9] = { 0./255., 102./255., 228./255., 231./255., 177./255., 124./255., 137./255., 20./255., 244./255.};
2438  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2439  }
2440  break;
2441 
2442  // Alpine
2443  case 63:
2444  {
2445  Double_t red[9] = { 50./255., 56./255., 63./255., 68./255., 93./255., 121./255., 165./255., 192./255., 241./255.};
2446  Double_t green[9] = { 66./255., 81./255., 91./255., 96./255., 111./255., 128./255., 155./255., 189./255., 241./255.};
2447  Double_t blue[9] = { 97./255., 91./255., 75./255., 65./255., 77./255., 103./255., 143./255., 167./255., 217./255.};
2448  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2449  }
2450  break;
2451 
2452  // Aquamarine
2453  case 64:
2454  {
2455  Double_t red[9] = { 145./255., 166./255., 167./255., 156./255., 131./255., 114./255., 101./255., 112./255., 132./255.};
2456  Double_t green[9] = { 158./255., 178./255., 179./255., 181./255., 163./255., 154./255., 144./255., 152./255., 159./255.};
2457  Double_t blue[9] = { 190./255., 199./255., 201./255., 192./255., 176./255., 169./255., 160./255., 166./255., 190./255.};
2458  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2459  }
2460  break;
2461 
2462  // Army
2463  case 65:
2464  {
2465  Double_t red[9] = { 93./255., 91./255., 99./255., 108./255., 130./255., 125./255., 132./255., 155./255., 174./255.};
2466  Double_t green[9] = { 126./255., 124./255., 128./255., 129./255., 131./255., 121./255., 119./255., 153./255., 173./255.};
2467  Double_t blue[9] = { 103./255., 94./255., 87./255., 85./255., 80./255., 85./255., 107./255., 120./255., 146./255.};
2468  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2469  }
2470  break;
2471 
2472  // Atlantic
2473  case 66:
2474  {
2475  Double_t red[9] = { 24./255., 40./255., 69./255., 90./255., 104./255., 114./255., 120./255., 132./255., 103./255.};
2476  Double_t green[9] = { 29./255., 52./255., 94./255., 127./255., 150./255., 162./255., 159./255., 151./255., 101./255.};
2477  Double_t blue[9] = { 29./255., 52./255., 96./255., 132./255., 162./255., 181./255., 184./255., 186./255., 131./255.};
2478  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2479  }
2480  break;
2481 
2482  // Aurora
2483  case 67:
2484  {
2485  Double_t red[9] = { 46./255., 38./255., 61./255., 92./255., 113./255., 121./255., 132./255., 150./255., 191./255.};
2486  Double_t green[9] = { 46./255., 36./255., 40./255., 69./255., 110./255., 135./255., 131./255., 92./255., 34./255.};
2487  Double_t blue[9] = { 46./255., 80./255., 74./255., 70./255., 81./255., 105./255., 165./255., 211./255., 225./255.};
2488  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2489  }
2490  break;
2491 
2492  // Avocado
2493  case 68:
2494  {
2495  Double_t red[9] = { 0./255., 4./255., 12./255., 30./255., 52./255., 101./255., 142./255., 190./255., 237./255.};
2496  Double_t green[9] = { 0./255., 40./255., 86./255., 121./255., 140./255., 172./255., 187./255., 213./255., 240./255.};
2497  Double_t blue[9] = { 0./255., 9./255., 14./255., 18./255., 21./255., 23./255., 27./255., 35./255., 101./255.};
2498  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2499  }
2500  break;
2501 
2502  // Beach
2503  case 69:
2504  {
2505  Double_t red[9] = { 198./255., 206./255., 206./255., 211./255., 198./255., 181./255., 161./255., 171./255., 244./255.};
2506  Double_t green[9] = { 103./255., 133./255., 150./255., 172./255., 178./255., 174./255., 163./255., 175./255., 244./255.};
2507  Double_t blue[9] = { 49./255., 54./255., 55./255., 66./255., 91./255., 130./255., 184./255., 224./255., 244./255.};
2508  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2509  }
2510  break;
2511 
2512  // Black Body
2513  case 70:
2514  {
2515  Double_t red[9] = { 243./255., 243./255., 240./255., 240./255., 241./255., 239./255., 186./255., 151./255., 129./255.};
2516  Double_t green[9] = { 0./255., 46./255., 99./255., 149./255., 194./255., 220./255., 183./255., 166./255., 147./255.};
2517  Double_t blue[9] = { 6./255., 8./255., 36./255., 91./255., 169./255., 235./255., 246./255., 240./255., 233./255.};
2518  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2519  }
2520  break;
2521 
2522  // Blue Green Yellow
2523  case 71:
2524  {
2525  Double_t red[9] = { 22./255., 19./255., 19./255., 25./255., 35./255., 53./255., 88./255., 139./255., 210./255.};
2526  Double_t green[9] = { 0./255., 32./255., 69./255., 108./255., 135./255., 159./255., 183./255., 198./255., 215./255.};
2527  Double_t blue[9] = { 77./255., 96./255., 110./255., 116./255., 110./255., 100./255., 90./255., 78./255., 70./255.};
2528  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2529  }
2530  break;
2531 
2532  // Brown Cyan
2533  case 72:
2534  {
2535  Double_t red[9] = { 68./255., 116./255., 165./255., 182./255., 189./255., 180./255., 145./255., 111./255., 71./255.};
2536  Double_t green[9] = { 37./255., 82./255., 135./255., 178./255., 204./255., 225./255., 221./255., 202./255., 147./255.};
2537  Double_t blue[9] = { 16./255., 55./255., 105./255., 147./255., 196./255., 226./255., 232./255., 224./255., 178./255.};
2538  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2539  }
2540  break;
2541 
2542  // CMYK
2543  case 73:
2544  {
2545  Double_t red[9] = { 61./255., 99./255., 136./255., 181./255., 213./255., 225./255., 198./255., 136./255., 24./255.};
2546  Double_t green[9] = { 149./255., 140./255., 96./255., 83./255., 132./255., 178./255., 190./255., 135./255., 22./255.};
2547  Double_t blue[9] = { 214./255., 203./255., 168./255., 135./255., 110./255., 100./255., 111./255., 113./255., 22./255.};
2548  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2549  }
2550  break;
2551 
2552  // Candy
2553  case 74:
2554  {
2555  Double_t red[9] = { 76./255., 120./255., 156./255., 183./255., 197./255., 180./255., 162./255., 154./255., 140./255.};
2556  Double_t green[9] = { 34./255., 35./255., 42./255., 69./255., 102./255., 137./255., 164./255., 188./255., 197./255.};
2557  Double_t blue[9] = { 64./255., 69./255., 78./255., 105./255., 142./255., 177./255., 205./255., 217./255., 198./255.};
2558  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2559  }
2560  break;
2561 
2562  // Cherry
2563  case 75:
2564  {
2565  Double_t red[9] = { 37./255., 102./255., 157./255., 188./255., 196./255., 214./255., 223./255., 235./255., 251./255.};
2566  Double_t green[9] = { 37./255., 29./255., 25./255., 37./255., 67./255., 91./255., 132./255., 185./255., 251./255.};
2567  Double_t blue[9] = { 37./255., 32./255., 33./255., 45./255., 66./255., 98./255., 137./255., 187./255., 251./255.};
2568  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2569  }
2570  break;
2571 
2572  // Coffee
2573  case 76:
2574  {
2575  Double_t red[9] = { 79./255., 100./255., 119./255., 137./255., 153./255., 172./255., 192./255., 205./255., 250./255.};
2576  Double_t green[9] = { 63./255., 79./255., 93./255., 103./255., 115./255., 135./255., 167./255., 196./255., 250./255.};
2577  Double_t blue[9] = { 51./255., 59./255., 66./255., 61./255., 62./255., 70./255., 110./255., 160./255., 250./255.};
2578  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2579  }
2580  break;
2581 
2582  // Dark Rain Bow
2583  case 77:
2584  {
2585  Double_t red[9] = { 43./255., 44./255., 50./255., 66./255., 125./255., 172./255., 178./255., 155./255., 157./255.};
2586  Double_t green[9] = { 63./255., 63./255., 85./255., 101./255., 138./255., 163./255., 122./255., 51./255., 39./255.};
2587  Double_t blue[9] = { 121./255., 101./255., 58./255., 44./255., 47./255., 55./255., 57./255., 44./255., 43./255.};
2588  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2589  }
2590  break;
2591 
2592  // Dark Terrain
2593  case 78:
2594  {
2595  Double_t red[9] = { 0./255., 41./255., 62./255., 79./255., 90./255., 87./255., 99./255., 140./255., 228./255.};
2596  Double_t green[9] = { 0./255., 57./255., 81./255., 93./255., 85./255., 70./255., 71./255., 125./255., 228./255.};
2597  Double_t blue[9] = { 95./255., 91./255., 91./255., 82./255., 60./255., 43./255., 44./255., 112./255., 228./255.};
2598  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2599  }
2600  break;
2601 
2602  // Fall
2603  case 79:
2604  {
2605  Double_t red[9] = { 49./255., 59./255., 72./255., 88./255., 114./255., 141./255., 176./255., 205./255., 222./255.};
2606  Double_t green[9] = { 78./255., 72./255., 66./255., 57./255., 59./255., 75./255., 106./255., 142./255., 173./255.};
2607  Double_t blue[9] = { 78./255., 55./255., 46./255., 40./255., 39./255., 39./255., 40./255., 41./255., 47./255.};
2608  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2609  }
2610  break;
2611 
2612  // Fruit Punch
2613  case 80:
2614  {
2615  Double_t red[9] = { 243./255., 222./255., 201./255., 185./255., 165./255., 158./255., 166./255., 187./255., 219./255.};
2616  Double_t green[9] = { 94./255., 108./255., 132./255., 135./255., 125./255., 96./255., 68./255., 51./255., 61./255.};
2617  Double_t blue[9] = { 7./255., 9./255., 12./255., 19./255., 45./255., 89./255., 118./255., 146./255., 118./255.};
2618  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2619  }
2620  break;
2621 
2622  // Fuchsia
2623  case 81:
2624  {
2625  Double_t red[9] = { 19./255., 44./255., 74./255., 105./255., 137./255., 166./255., 194./255., 206./255., 220./255.};
2626  Double_t green[9] = { 19./255., 28./255., 40./255., 55./255., 82./255., 110./255., 159./255., 181./255., 220./255.};
2627  Double_t blue[9] = { 19./255., 42./255., 68./255., 96./255., 129./255., 157./255., 188./255., 203./255., 220./255.};
2628  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2629  }
2630  break;
2631 
2632  // Grey Yellow
2633  case 82:
2634  {
2635  Double_t red[9] = { 33./255., 44./255., 70./255., 99./255., 140./255., 165./255., 199./255., 211./255., 216./255.};
2636  Double_t green[9] = { 38./255., 50./255., 76./255., 105./255., 140./255., 165./255., 191./255., 189./255., 167./255.};
2637  Double_t blue[9] = { 55./255., 67./255., 97./255., 124./255., 140./255., 166./255., 163./255., 129./255., 52./255.};
2638  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2639  }
2640  break;
2641 
2642  // Green Brown Terrain
2643  case 83:
2644  {
2645  Double_t red[9] = { 0./255., 33./255., 73./255., 124./255., 136./255., 152./255., 159./255., 171./255., 223./255.};
2646  Double_t green[9] = { 0./255., 43./255., 92./255., 124./255., 134./255., 126./255., 121./255., 144./255., 223./255.};
2647  Double_t blue[9] = { 0./255., 43./255., 68./255., 76./255., 73./255., 64./255., 72./255., 114./255., 223./255.};
2648  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2649  }
2650  break;
2651 
2652  // Green Pink
2653  case 84:
2654  {
2655  Double_t red[9] = { 5./255., 18./255., 45./255., 124./255., 193./255., 223./255., 205./255., 128./255., 49./255.};
2656  Double_t green[9] = { 48./255., 134./255., 207./255., 230./255., 193./255., 113./255., 28./255., 0./255., 7./255.};
2657  Double_t blue[9] = { 6./255., 15./255., 41./255., 121./255., 193./255., 226./255., 208./255., 130./255., 49./255.};
2658  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2659  }
2660  break;
2661 
2662  // Island
2663  case 85:
2664  {
2665  Double_t red[9] = { 180./255., 106./255., 104./255., 135./255., 164./255., 188./255., 189./255., 165./255., 144./255.};
2666  Double_t green[9] = { 72./255., 126./255., 154./255., 184./255., 198./255., 207./255., 205./255., 190./255., 179./255.};
2667  Double_t blue[9] = { 41./255., 120./255., 158./255., 188./255., 194./255., 181./255., 145./255., 100./255., 62./255.};
2668  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2669  }
2670  break;
2671 
2672  // Lake
2673  case 86:
2674  {
2675  Double_t red[9] = { 57./255., 72./255., 94./255., 117./255., 136./255., 154./255., 174./255., 192./255., 215./255.};
2676  Double_t green[9] = { 0./255., 33./255., 68./255., 109./255., 140./255., 171./255., 192./255., 196./255., 209./255.};
2677  Double_t blue[9] = { 116./255., 137./255., 173./255., 201./255., 200./255., 201./255., 203./255., 190./255., 187./255.};
2678  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2679  }
2680  break;
2681 
2682  // Light Temperature
2683  case 87:
2684  {
2685  Double_t red[9] = { 31./255., 71./255., 123./255., 160./255., 210./255., 222./255., 214./255., 199./255., 183./255.};
2686  Double_t green[9] = { 40./255., 117./255., 171./255., 211./255., 231./255., 220./255., 190./255., 132./255., 65./255.};
2687  Double_t blue[9] = { 234./255., 214./255., 228./255., 222./255., 210./255., 160./255., 105./255., 60./255., 34./255.};
2688  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2689  }
2690  break;
2691 
2692  // Light Terrain
2693  case 88:
2694  {
2695  Double_t red[9] = { 123./255., 108./255., 109./255., 126./255., 154./255., 172./255., 188./255., 196./255., 218./255.};
2696  Double_t green[9] = { 184./255., 138./255., 130./255., 133./255., 154./255., 175./255., 188./255., 196./255., 218./255.};
2697  Double_t blue[9] = { 208./255., 130./255., 109./255., 99./255., 110./255., 122./255., 150./255., 171./255., 218./255.};
2698  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2699  }
2700  break;
2701 
2702  // Mint
2703  case 89:
2704  {
2705  Double_t red[9] = { 105./255., 106./255., 122./255., 143./255., 159./255., 172./255., 176./255., 181./255., 207./255.};
2706  Double_t green[9] = { 252./255., 197./255., 194./255., 187./255., 174./255., 162./255., 153./255., 136./255., 125./255.};
2707  Double_t blue[9] = { 146./255., 133./255., 144./255., 155./255., 163./255., 167./255., 166./255., 162./255., 174./255.};
2708  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2709  }
2710  break;
2711 
2712  // Neon
2713  case 90:
2714  {
2715  Double_t red[9] = { 171./255., 141./255., 145./255., 152./255., 154./255., 159./255., 163./255., 158./255., 177./255.};
2716  Double_t green[9] = { 236./255., 143./255., 100./255., 63./255., 53./255., 55./255., 44./255., 31./255., 6./255.};
2717  Double_t blue[9] = { 59./255., 48./255., 46./255., 44./255., 42./255., 54./255., 82./255., 112./255., 179./255.};
2718  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2719  }
2720  break;
2721 
2722  // Pastel
2723  case 91:
2724  {
2725  Double_t red[9] = { 180./255., 190./255., 209./255., 223./255., 204./255., 228./255., 205./255., 152./255., 91./255.};
2726  Double_t green[9] = { 93./255., 125./255., 147./255., 172./255., 181./255., 224./255., 233./255., 198./255., 158./255.};
2727  Double_t blue[9] = { 236./255., 218./255., 160./255., 133./255., 114./255., 132./255., 162./255., 220./255., 218./255.};
2728  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2729  }
2730  break;
2731 
2732  // Pearl
2733  case 92:
2734  {
2735  Double_t red[9] = { 225./255., 183./255., 162./255., 135./255., 115./255., 111./255., 119./255., 145./255., 211./255.};
2736  Double_t green[9] = { 205./255., 177./255., 166./255., 135./255., 124./255., 117./255., 117./255., 132./255., 172./255.};
2737  Double_t blue[9] = { 186./255., 165./255., 155./255., 135./255., 126./255., 130./255., 150./255., 178./255., 226./255.};
2738  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2739  }
2740  break;
2741 
2742  // Pigeon
2743  case 93:
2744  {
2745  Double_t red[9] = { 39./255., 43./255., 59./255., 63./255., 80./255., 116./255., 153./255., 177./255., 223./255.};
2746  Double_t green[9] = { 39./255., 43./255., 59./255., 74./255., 91./255., 114./255., 139./255., 165./255., 223./255.};
2747  Double_t blue[9] = { 39./255., 50./255., 59./255., 70./255., 85./255., 115./255., 151./255., 176./255., 223./255.};
2748  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2749  }
2750  break;
2751 
2752  // Plum
2753  case 94:
2754  {
2755  Double_t red[9] = { 0./255., 38./255., 60./255., 76./255., 84./255., 89./255., 101./255., 128./255., 204./255.};
2756  Double_t green[9] = { 0./255., 10./255., 15./255., 23./255., 35./255., 57./255., 83./255., 123./255., 199./255.};
2757  Double_t blue[9] = { 0./255., 11./255., 22./255., 40./255., 63./255., 86./255., 97./255., 94./255., 85./255.};
2758  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2759  }
2760  break;
2761 
2762  // Red Blue
2763  case 95:
2764  {
2765  Double_t red[9] = { 94./255., 112./255., 141./255., 165./255., 167./255., 140./255., 91./255., 49./255., 27./255.};
2766  Double_t green[9] = { 27./255., 46./255., 88./255., 135./255., 166./255., 161./255., 135./255., 97./255., 58./255.};
2767  Double_t blue[9] = { 42./255., 52./255., 81./255., 106./255., 139./255., 158./255., 155./255., 137./255., 116./255.};
2768  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2769  }
2770  break;
2771 
2772  // Rose
2773  case 96:
2774  {
2775  Double_t red[9] = { 30./255., 49./255., 79./255., 117./255., 135./255., 151./255., 146./255., 138./255., 147./255.};
2776  Double_t green[9] = { 63./255., 60./255., 72./255., 90./255., 94./255., 94./255., 68./255., 46./255., 16./255.};
2777  Double_t blue[9] = { 18./255., 28./255., 41./255., 56./255., 62./255., 63./255., 50./255., 36./255., 21./255.};
2778  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2779  }
2780  break;
2781 
2782  // Rust
2783  case 97:
2784  {
2785  Double_t red[9] = { 0./255., 30./255., 63./255., 101./255., 143./255., 152./255., 169./255., 187./255., 230./255.};
2786  Double_t green[9] = { 0./255., 14./255., 28./255., 42./255., 58./255., 61./255., 67./255., 74./255., 91./255.};
2787  Double_t blue[9] = { 39./255., 26./255., 21./255., 18./255., 15./255., 14./255., 14./255., 13./255., 13./255.};
2788  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2789  }
2790  break;
2791 
2792  // Sandy Terrain
2793  case 98:
2794  {
2795  Double_t red[9] = { 149./255., 140./255., 164./255., 179./255., 182./255., 181./255., 131./255., 87./255., 61./255.};
2796  Double_t green[9] = { 62./255., 70./255., 107./255., 136./255., 144./255., 138./255., 117./255., 87./255., 74./255.};
2797  Double_t blue[9] = { 40./255., 38./255., 45./255., 49./255., 49./255., 49./255., 38./255., 32./255., 34./255.};
2798  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2799  }
2800  break;
2801 
2802  // Sienna
2803  case 99:
2804  {
2805  Double_t red[9] = { 99./255., 112./255., 148./255., 165./255., 179./255., 182./255., 183./255., 183./255., 208./255.};
2806  Double_t green[9] = { 39./255., 40./255., 57./255., 79./255., 104./255., 127./255., 148./255., 161./255., 198./255.};
2807  Double_t blue[9] = { 15./255., 16./255., 18./255., 33./255., 51./255., 79./255., 103./255., 129./255., 177./255.};
2808  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2809  }
2810  break;
2811 
2812  // Solar
2813  case 100:
2814  {
2815  Double_t red[9] = { 99./255., 116./255., 154./255., 174./255., 200./255., 196./255., 201./255., 201./255., 230./255.};
2816  Double_t green[9] = { 0./255., 0./255., 8./255., 32./255., 58./255., 83./255., 119./255., 136./255., 173./255.};
2817  Double_t blue[9] = { 5./255., 6./255., 7./255., 9./255., 9./255., 14./255., 17./255., 19./255., 24./255.};
2818  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2819  }
2820  break;
2821 
2822  // South West
2823  case 101:
2824  {
2825  Double_t red[9] = { 82./255., 106./255., 126./255., 141./255., 155./255., 163./255., 142./255., 107./255., 66./255.};
2826  Double_t green[9] = { 62./255., 44./255., 69./255., 107./255., 135./255., 152./255., 149./255., 132./255., 119./255.};
2827  Double_t blue[9] = { 39./255., 25./255., 31./255., 60./255., 73./255., 68./255., 49./255., 72./255., 188./255.};
2828  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2829  }
2830  break;
2831 
2832  // Starry Night
2833  case 102:
2834  {
2835  Double_t red[9] = { 18./255., 29./255., 44./255., 72./255., 116./255., 158./255., 184./255., 208./255., 221./255.};
2836  Double_t green[9] = { 27./255., 46./255., 71./255., 105./255., 146./255., 177./255., 189./255., 190./255., 183./255.};
2837  Double_t blue[9] = { 39./255., 55./255., 80./255., 108./255., 130./255., 133./255., 124./255., 100./255., 76./255.};
2838  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2839  }
2840  break;
2841 
2842  // Sunset
2843  case 103:
2844  {
2845  Double_t red[9] = { 0./255., 48./255., 119./255., 173./255., 212./255., 224./255., 228./255., 228./255., 245./255.};
2846  Double_t green[9] = { 0./255., 13./255., 30./255., 47./255., 79./255., 127./255., 167./255., 205./255., 245./255.};
2847  Double_t blue[9] = { 0./255., 68./255., 75./255., 43./255., 16./255., 22./255., 55./255., 128./255., 245./255.};
2848  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2849  }
2850  break;
2851 
2852  // Temperature Map
2853  case 104:
2854  {
2855  Double_t red[9] = { 34./255., 70./255., 129./255., 187./255., 225./255., 226./255., 216./255., 193./255., 179./255.};
2856  Double_t green[9] = { 48./255., 91./255., 147./255., 194./255., 226./255., 229./255., 196./255., 110./255., 12./255.};
2857  Double_t blue[9] = { 234./255., 212./255., 216./255., 224./255., 206./255., 110./255., 53./255., 40./255., 29./255.};
2858  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2859  }
2860  break;
2861 
2862  // Thermometer
2863  case 105:
2864  {
2865  Double_t red[9] = { 30./255., 55./255., 103./255., 147./255., 174./255., 203./255., 188./255., 151./255., 105./255.};
2866  Double_t green[9] = { 0./255., 65./255., 138./255., 182./255., 187./255., 175./255., 121./255., 53./255., 9./255.};
2867  Double_t blue[9] = { 191./255., 202./255., 212./255., 208./255., 171./255., 140./255., 97./255., 57./255., 30./255.};
2868  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2869  }
2870  break;
2871 
2872  // Valentine
2873  case 106:
2874  {
2875  Double_t red[9] = { 112./255., 97./255., 113./255., 125./255., 138./255., 159./255., 178./255., 188./255., 225./255.};
2876  Double_t green[9] = { 16./255., 17./255., 24./255., 37./255., 56./255., 81./255., 110./255., 136./255., 189./255.};
2877  Double_t blue[9] = { 38./255., 35./255., 46./255., 59./255., 78./255., 103./255., 130./255., 152./255., 201./255.};
2878  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2879  }
2880  break;
2881 
2882  // Visible Spectrum
2883  case 107:
2884  {
2885  Double_t red[9] = { 18./255., 72./255., 5./255., 23./255., 29./255., 201./255., 200./255., 98./255., 29./255.};
2886  Double_t green[9] = { 0./255., 0./255., 43./255., 167./255., 211./255., 117./255., 0./255., 0./255., 0./255.};
2887  Double_t blue[9] = { 51./255., 203./255., 177./255., 26./255., 10./255., 9./255., 8./255., 3./255., 0./255.};
2888  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2889  }
2890  break;
2891 
2892  // Water Melon
2893  case 108:
2894  {
2895  Double_t red[9] = { 19./255., 42./255., 64./255., 88./255., 118./255., 147./255., 175./255., 187./255., 205./255.};
2896  Double_t green[9] = { 19./255., 55./255., 89./255., 125./255., 154./255., 169./255., 161./255., 129./255., 70./255.};
2897  Double_t blue[9] = { 19./255., 32./255., 47./255., 70./255., 100./255., 128./255., 145./255., 130./255., 75./255.};
2898  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2899  }
2900  break;
2901 
2902  // Cool
2903  case 109:
2904  {
2905  Double_t red[9] = { 33./255., 31./255., 42./255., 68./255., 86./255., 111./255., 141./255., 172./255., 227./255.};
2906  Double_t green[9] = { 255./255., 175./255., 145./255., 106./255., 88./255., 55./255., 15./255., 0./255., 0./255.};
2907  Double_t blue[9] = { 255./255., 205./255., 202./255., 203./255., 208./255., 205./255., 203./255., 206./255., 231./255.};
2908  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2909  }
2910  break;
2911 
2912  // Copper
2913  case 110:
2914  {
2915  Double_t red[9] = { 0./255., 25./255., 50./255., 79./255., 110./255., 145./255., 181./255., 201./255., 254./255.};
2916  Double_t green[9] = { 0./255., 16./255., 30./255., 46./255., 63./255., 82./255., 101./255., 124./255., 179./255.};
2917  Double_t blue[9] = { 0./255., 12./255., 21./255., 29./255., 39./255., 49./255., 61./255., 74./255., 103./255.};
2918  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2919  }
2920  break;
2921 
2922  // Gist Earth
2923  case 111:
2924  {
2925  Double_t red[9] = { 0./255., 13./255., 30./255., 44./255., 72./255., 120./255., 156./255., 200./255., 247./255.};
2926  Double_t green[9] = { 0./255., 36./255., 84./255., 117./255., 141./255., 153./255., 151./255., 158./255., 247./255.};
2927  Double_t blue[9] = { 0./255., 94./255., 100./255., 82./255., 56./255., 66./255., 76./255., 131./255., 247./255.};
2928  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2929  }
2930  break;
2931 
2932  // Viridis
2933  case 112:
2934  {
2935  Double_t red[9] = { 26./255., 51./255., 43./255., 33./255., 28./255., 35./255., 74./255., 144./255., 246./255.};
2936  Double_t green[9] = { 9./255., 24./255., 55./255., 87./255., 118./255., 150./255., 180./255., 200./255., 222./255.};
2937  Double_t blue[9] = { 30./255., 96./255., 112./255., 114./255., 112./255., 101./255., 72./255., 35./255., 0./255.};
2938  Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2939  }
2940  break;
2941 
2942  default:
2943  ::Error("SetPalette", "Unknown palette number %d", ncolors);
2944  return;
2945  }
2946  paletteType = ncolors;
2947  if (Idx>0) fgPalettesList.fArray[paletteType-51] = (Double_t)Idx;
2948  else fgPalettesList.fArray[paletteType-51] = 0.;
2949  if (alpha > 0.) fgPalettesList.fArray[paletteType-51] += alpha/10.;
2950  return;
2951  }
2952 
2953  // set user defined palette
2954  if (colors) {
2955  fgPalette.Set(ncolors);
2956  for (i=0;i<ncolors;i++) fgPalette.fArray[i] = colors[i];
2957  } else {
2958  fgPalette.Set(TMath::Min(50,ncolors));
2959  for (i=0;i<TMath::Min(50,ncolors);i++) fgPalette.fArray[i] = palette[i];
2960  }
2961  paletteType = 3;
2962 }
2963 
UShort_t fBlue
Definition: GuiTypes.h:315
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:1420
#define fgPalettesList
Definition: TColor.cxx:46
Float_t fBlue
Definition: TColor.h:29
virtual void SetAlpha(Float_t a)
Definition: TColor.h:70
An array of TObjects.
Definition: TObjArray.h:39
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:2005
#define fgPalette
Definition: TColor.cxx:45
Float_t fHue
Definition: TColor.h:30
#define fgGrayscaleMode
Definition: TColor.cxx:44
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:527
const char Option_t
Definition: RtypesCore.h:62
Definition: Rtypes.h:61
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:1808
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:1967
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:1552
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:1327
#define gROOT
Definition: TROOT.h:340
virtual void ls(Option_t *option="") const
List this color with its attributes.
Definition: TColor.cxx:1476
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:76
const Bool_t kFALSE
Definition: Rtypes.h:92
Float_t GetGreen() const
Definition: TColor.h:61
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:1337
Array of integers (32 bits per element).
Definition: TArrayI.h:29
Float_t fAlpha
Definition: TColor.h:33
static void SetPalette(Int_t ncolors, Int_t *colors, Float_t alpha=1.)
Static function.
Definition: TColor.cxx:2262
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:1955
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:395
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:1315
void Class()
Definition: Class.C:29
Definition: Rtypes.h:62
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
Float_t GetBlue() const
Definition: TColor.h:62
Float_t fLight
Definition: TColor.h:31
virtual void Copy(TObject &named) const
Copy this to obj.
Definition: TNamed.cxx:83
if(pyself &&pyself!=Py_None)
Float_t GetLight() const
Definition: TColor.h:64
Float_t fGreen
Definition: TColor.h:28
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:1900
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:1485
virtual ~TColor()
Color destructor.
Definition: TColor.cxx:989
Float_t GetSaturation() const
Definition: TColor.h:65
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:1494
static void RGBtoHLS(Float_t r, Float_t g, Float_t b, Float_t &h, Float_t &l, Float_t &s)
Definition: TColor.h:81
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:1354
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:1776
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
Definition: TObjArray.cxx:221
static void NeedGraphicsLibs()
Static method.
ROOT::R::TRInterface & r
Definition: Object.C:4
Definition: Rtypes.h:62
Float_t fSaturation
Definition: TColor.h:32
static void CreateColorsRectangle(Int_t offset, const char *name, UChar_t *rgb)
Create the "rectangular" colors in the color wheel.
Definition: TColor.cxx:1207
virtual void GetRGB(Float_t &r, Float_t &g, Float_t &b) const
Definition: TColor.h:54
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2321
const char * AsHexString() const
Return color as hexadecimal string.
Definition: TColor.cxx:1134
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:1666
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
TColor()
Default constructor.
Definition: TColor.cxx:917
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:1839
Int_t fNumber
Definition: TColor.h:25
static void CreateColorWheel()
Static function steering the creation of all colors in the color wheel.
Definition: TColor.cxx:1227
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:1862
Color * colors
Definition: X3DBuffer.c:19
static Int_t gHighestColorIndex
Definition: TColor.cxx:42
virtual Int_t GetSize() const
Definition: TCollection.h:95
double f(double x)
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:1171
virtual void SetRGB(Float_t r, Float_t g, Float_t b)
Initialize this color and its associated colors.
Definition: TColor.cxx:1605
The color creation and management class.
Definition: TColor.h:23
Float_t GetRed() const
Definition: TColor.h:60
Definition: Rtypes.h:61
Array of doubles (64 bits per element).
Definition: TArrayD.h:29
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:27
#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:2013
static void CreateColorsCircle(Int_t offset, const char *name, UChar_t *rgb)
Create the "circle" colors in the color wheel.
Definition: TColor.cxx:1187
Definition: Rtypes.h:62
Float_t GetAlpha() const
Definition: TColor.h:66
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition: TColor.cxx:1008
ClassImp(TColor) namespace
Definition: TColor.cxx:25
Definition: Rtypes.h:61
unsigned char UChar_t
Definition: RtypesCore.h:34
Float_t GetHue() const
Definition: TColor.h:63
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
void Allocate()
Make this color known to the graphics system.
Definition: TColor.cxx:1651
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:1155
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:2074
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:1379
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:1938
Int_t GetNumber() const
Definition: TColor.h:58
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904