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