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