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