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