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 auto 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 auto 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 auto 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 auto w = new TColorWheel();
158 auto 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 auto w = new TColorWheel();
208 auto 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 auto 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 auto c2 = new TCanvas("c2","c2",0,0,600,400);
252 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
376 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
385 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
394 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
404 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
413 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
422 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
432 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
441 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
450 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
460 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
469 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
478 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
488 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
497 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
506 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
516 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
525 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
534 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
544 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
553 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
562 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
572 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
581 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
590 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
600 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
609 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
618 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
628 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
637 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
646 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
656 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
665 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
674 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
684 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
693 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
702 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
712 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
721 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
730 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
746 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
755 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
764 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
774 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
783 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
792 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
802 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
811 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
820 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
830 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
839 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
848 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
858 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
867 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
876 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
886 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
895 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
904 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
914 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
923 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
932 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
942 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
951 auto 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 auto c = new TCanvas("c","c",0,0,300,300);
960 auto 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 auto 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 auto 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 method returning color index for a color specified by name.
1989/// The list of defined colors and their names is given by TColor::ListColors.
1990/// If the specified color name does not exist -1 is returned.
1991
1992Int_t TColor::GetColorByName(const char *colorname)
1993{
1994 TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
1995 const Int_t ncolors = colors->GetSize();
1996 TColor *color = nullptr;
1997 TString colname;
1998
1999 for (Int_t i = 0; i<ncolors; i++) {
2000 color = (TColor*)colors->At(i);
2001 if (color) {
2002 colname = color->GetName();
2003 if (!colname.CompareTo(colorname)) return i;
2004 }
2005 }
2006
2007 return -1;
2008}
2009
2010////////////////////////////////////////////////////////////////////////////////
2011/// Static function: Returns the bright color number corresponding to n
2012/// If the TColor object does not exist, it is created.
2013/// The convention is that the bright color nb = n+150
2014
2016{
2017 if (n < 0) return -1;
2018
2019 // Get list of all defined colors
2020 TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
2021 Int_t ncolors = colors->GetSize();
2022 // Get existing color at index n
2023 TColor *color = nullptr;
2024 if (n < ncolors) color = (TColor*)colors->At(n);
2025 if (!color) return -1;
2026
2027 //Get the rgb of the new bright color corresponding to color n
2028 Float_t r,g,b;
2029 HLStoRGB(color->GetHue(), 1.2f*color->GetLight(), color->GetSaturation(), r, g, b);
2030
2031 //Build the bright color (unless the slot nb is already used)
2032 Int_t nb = n+150;
2033 TColor *colorb = nullptr;
2034 if (nb < ncolors) colorb = (TColor*)colors->At(nb);
2035 if (colorb) return nb;
2036 colorb = new TColor(nb,r,g,b);
2037 colorb->SetName(TString::Format("%s_bright",color->GetName()).Data());
2038 colors->AddAtAndExpand(colorb,nb);
2039 return nb;
2040}
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Static function: Returns the dark color number corresponding to n
2044/// If the TColor object does not exist, it is created.
2045/// The convention is that the dark color nd = n+100
2046
2048{
2049 if (n < 0) return -1;
2050
2051 // Get list of all defined colors
2052 TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
2053 Int_t ncolors = colors->GetSize();
2054 // Get existing color at index n
2055 TColor *color = nullptr;
2056 if (n < ncolors) color = (TColor*)colors->At(n);
2057 if (!color) return -1;
2058
2059 //Get the rgb of the new dark color corresponding to color n
2060 Float_t r,g,b;
2061 HLStoRGB(color->GetHue(), 0.7f*color->GetLight(), color->GetSaturation(), r, g, b);
2062
2063 //Build the dark color (unless the slot nd is already used)
2064 Int_t nd = n+100;
2065 TColor *colord = nullptr;
2066 if (nd < ncolors) colord = (TColor*)colors->At(nd);
2067 if (colord) return nd;
2068 colord = new TColor(nd,r,g,b);
2069 colord->SetName(TString::Format("%s_dark",color->GetName()).Data());
2070 colors->AddAtAndExpand(colord,nd);
2071 return nd;
2072}
2073
2074////////////////////////////////////////////////////////////////////////////////
2075/// Static function: Returns the transparent color number corresponding to n.
2076/// The opacity level is given by the alpha value a. If a color with the same
2077/// RGBa values already exists it is returned.
2078
2080{
2081 if (n < 0) return -1;
2082
2083 TColor *color = gROOT->GetColor(n);
2084 if (color) {
2085 TObjArray *colors = (TObjArray *)gROOT->GetListOfColors();
2086 Int_t ncolors = colors->GetSize();
2087 TColor *col = nullptr;
2088 for (Int_t i = 0; i < ncolors; i++) {
2089 col = (TColor *)colors->At(i);
2090 if (col) {
2091 if (col->GetRed() == color->GetRed() && col->GetGreen() == color->GetGreen() &&
2092 col->GetBlue() == color->GetBlue() && col->GetAlpha() == a)
2093 return col->GetNumber();
2094 }
2095 }
2096 TColor *colort = new TColor(gROOT->GetListOfColors()->GetLast()+1,
2097 color->GetRed(), color->GetGreen(), color->GetBlue());
2098 colort->SetAlpha(a);
2099 colort->SetName(TString::Format("%s_transparent",color->GetName()).Data());
2100 return colort->GetNumber();
2101 } else {
2102 ::Error("TColor::GetColorTransparent", "color with index %d not defined", n);
2103 return -1;
2104 }
2105}
2106
2107////////////////////////////////////////////////////////////////////////////////
2108/// Static function: Returns the linear gradient color number corresponding to specified parameters.
2109/// First parameter set direction as angle in grad. Value 0 is horizontal direction, 90 - vertical
2110/// List of colors defines interpolation colors for the gradient
2111/// Optional positions can define relative color positions and must be sorted array of values between 0 and 1.
2112/// If such gradient not exists - it will be created new
2113/// Returns -1 if wrong parameters where specified
2114
2115Int_t TColor::GetLinearGradient(Double_t angle, const std::vector<Int_t> &colors, const std::vector<Double_t> &positions)
2116{
2117 if (colors.size() < 2) {
2118 ::Error("TColor::GetLinearGradient", "number of specified colors %d not enough to create gradients", (int) colors.size());
2119 return -1;
2120 }
2121
2122 std::vector<Double_t> raw_colors(colors.size()*4);
2123 std::vector<Double_t> raw_positions(colors.size());
2124 for (unsigned indx = 0; indx < colors.size(); indx++) {
2125 TColor *color = gROOT->GetColor(colors[indx]);
2126 if (!color) {
2127 ::Error("TColor::GetLinearGradient", "Not able to get %d color", (int) colors.size());
2128 return -1;
2129 }
2130 raw_colors[indx*4] = color->GetRed();
2131 raw_colors[indx*4+1] = color->GetGreen();
2132 raw_colors[indx*4+2] = color->GetBlue();
2133 raw_colors[indx*4+3] = color->GetAlpha();
2134
2135 raw_positions[indx] = indx < positions.size() ? positions[indx] : indx / (colors.size() - 1.);
2136 }
2137
2138 Double_t _cos = std::cos(angle / 180. * 3.1415), _sin = std::sin(angle / 180. * 3.1415);
2139 Double_t x0 = (_cos >= 0. ? 0. : 1.), y0 = (_sin >= 0. ? 0. : 1.);
2140 Double_t scale = TMath::Max(TMath::Abs(_cos), TMath::Abs(_sin));
2141
2142 TLinearGradient::Point start(x0, y0), end(x0 + _cos/scale, y0 + _sin/scale);
2143
2144
2145 TObjArray *root_colors = (TObjArray*) gROOT->GetListOfColors();
2146
2147 TIter iter(root_colors);
2148
2149 while (auto col = static_cast<TColor *>(iter())) {
2150 if (col->IsA() != TLinearGradient::Class())
2151 continue;
2152
2153 auto grad = static_cast<TLinearGradient *>(col);
2154
2155 if (grad->GetNumberOfSteps() != colors.size())
2156 continue;
2157
2158 Bool_t match = kTRUE;
2159 for (unsigned n = 0; n < raw_colors.size(); ++n)
2160 if (TMath::Abs(raw_colors[n] - grad->GetColors()[n]) > 1e-3)
2161 match = kFALSE;
2162
2163 for (unsigned n = 0; n < raw_positions.size(); ++n)
2164 if (TMath::Abs(raw_positions[n] - grad->GetColorPositions()[n]) > 1e-2)
2165 match = kFALSE;
2166
2167 if (TMath::Abs(grad->GetStart().fX - start.fX) > 1e-2 ||
2168 TMath::Abs(grad->GetStart().fY - start.fY) > 1e-2 ||
2169 TMath::Abs(grad->GetEnd().fX - end.fX) > 1e-2 ||
2170 TMath::Abs(grad->GetEnd().fY - end.fY) > 1e-2)
2171 match = kFALSE;
2172
2173 if (match)
2174 return col->GetNumber();
2175 }
2176
2177 auto grad = new TLinearGradient(root_colors->GetLast() + 1, colors.size(), raw_positions.data(), raw_colors.data());
2178
2179 grad->SetStartEnd(start, end);
2180
2181 return grad->GetNumber();
2182}
2183
2184////////////////////////////////////////////////////////////////////////////////
2185/// Static function: Returns the radial gradient color number corresponding to specified parameters.
2186/// First parameter set direction as angle in grad. Value 0 is horizontal direction, 90 - vertical
2187/// List of colors defines interpolation colors for the gradient
2188/// Optional positions can define relative color positions and must be sorted array of values between 0 and 1.
2189/// If such gradient not exists - it will be created new
2190/// Returns -1 if wrong parameter where specified
2191
2192Int_t TColor::GetRadialGradient(Double_t radius, const std::vector<Int_t> &colors, const std::vector<Double_t> &positions)
2193{
2194 if (colors.size() < 2) {
2195 ::Error("TColor::GetRadialGradient", "number of specified colors %d not enough to create gradients", (int) colors.size());
2196 return -1;
2197 }
2198
2199 std::vector<Double_t> raw_colors(colors.size()*4);
2200 std::vector<Double_t> raw_positions(colors.size());
2201 for (unsigned indx = 0; indx < colors.size(); indx++) {
2202 TColor *color = gROOT->GetColor(colors[indx]);
2203 if (!color) {
2204 ::Error("TColor::GetRadialGradient", "Not able to get %d color", (int) colors.size());
2205 return -1;
2206 }
2207 raw_colors[indx*4] = color->GetRed();
2208 raw_colors[indx*4+1] = color->GetGreen();
2209 raw_colors[indx*4+2] = color->GetBlue();
2210 raw_colors[indx*4+3] = color->GetAlpha();
2211
2212 raw_positions[indx] = indx < positions.size() ? positions[indx] : indx / (colors.size() - 1.);
2213 }
2214
2215 TRadialGradient::Point start(0.5, 0.5);
2216
2217 TObjArray *root_colors = (TObjArray*) gROOT->GetListOfColors();
2218
2219 TIter iter(root_colors);
2220
2221 while (auto col = static_cast<TColor *>(iter())) {
2222 if (col->IsA() != TRadialGradient::Class())
2223 continue;
2224
2225 auto grad = static_cast<TRadialGradient *>(col);
2226
2227 if (grad->GetNumberOfSteps() != colors.size())
2228 continue;
2229
2230 if (grad->GetGradientType() != TRadialGradient::kSimple)
2231 continue;
2232
2233 Bool_t match = kTRUE;
2234 for (unsigned n = 0; n < raw_colors.size(); ++n)
2235 if (TMath::Abs(raw_colors[n] - grad->GetColors()[n]) > 1e-3)
2236 match = kFALSE;
2237
2238 for (unsigned n = 0; n < raw_positions.size(); ++n)
2239 if (TMath::Abs(raw_positions[n] - grad->GetColorPositions()[n]) > 1e-2)
2240 match = kFALSE;
2241
2242 if (TMath::Abs(grad->GetStart().fX - start.fX) > 1e-2 ||
2243 TMath::Abs(grad->GetStart().fY - start.fY) > 1e-2 ||
2244 TMath::Abs(grad->GetR1() - radius) > 1e-2)
2245 match = kFALSE;
2246
2247 if (match)
2248 return col->GetNumber();
2249 }
2250
2251 auto grad = new TRadialGradient(root_colors->GetLast() + 1, colors.size(), raw_positions.data(), raw_colors.data());
2252
2253 grad->SetRadialGradient(start, radius);
2254
2255 return grad->GetNumber();
2256}
2257
2258
2259////////////////////////////////////////////////////////////////////////////////
2260/// Static function: Returns a free color index which can be used to define
2261/// a user custom color.
2262///
2263/// ~~~ {.cpp}
2264/// Int_t ci = TColor::GetFreeColorIndex();
2265/// auto color = new TColor(ci, 0.1, 0.2, 0.3);
2266/// ~~~
2267
2269{
2270 return gHighestColorIndex+1;
2271}
2272
2273////////////////////////////////////////////////////////////////////////////////
2274/// List `nb` colors from the color index `ci`.
2275/// If `nb=0` all the colors are printed.
2276/// If showEmpty is set to kTRUE, empty color indices are also printed
2277
2278void TColor::ListColors(Int_t ci, Int_t nb, Bool_t showEmpty)
2279{
2280 TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
2281 const Int_t ncolors = colors->GetSize();
2282 Int_t last = ci+nb;
2283 if (nb==0 || last>=ncolors) last = ncolors;
2284 TColor *color = 0;
2285 Int_t nc =0 ;
2286
2287 printf(" +------+-------+-------+-------+-------+--------------------+--------------------+\n");
2288 printf(" | Idx | Red | Green | Blue | Alpha | Color Name | Color Title |\n");
2289 printf(" +------+-------+-------+-------+-------+--------------------+--------------------+\n");
2290
2291 for (Int_t i = ci; i<last; i++) {
2292 color = (TColor*)colors->At(i);
2293 if (color) {
2294 printf(" | %4d | %5.3f | %5.3f | %5.3f | %5.3f | %18s | %18s |\n", i,
2295 color->GetRed(),
2296 color->GetGreen(),
2297 color->GetBlue(),
2298 color->GetAlpha(),
2299 color->GetName(),
2300 color->GetTitle());
2301 nc++;
2302 } else if (showEmpty) {
2303 printf(" | %4d | ? | ? | ? | ? | ? | ? |\n",i);
2304 }
2305 }
2306 printf(" +------+-------+-------+-------+-------+--------------------+--------------------+\n");
2307 printf(" | Number of possible colors = %4d |\n",ncolors);
2308 printf(" | Number of defined colors between %4d and %4d = %4d |\n",ci,last,nc);
2309 printf(" | Number of free indeces between %4d and %4d = %4d |\n",ci,last,last-ci-nc);
2310 printf(" +--------------------------------------------------------------------------------+\n\n");
2311
2312}
2313
2314////////////////////////////////////////////////////////////////////////////////
2315/// Static method that given a color index number, returns the corresponding
2316/// pixel value. This pixel value can be used in the GUI classes. This call
2317/// does not work in batch mode since it needs to communicate with the
2318/// graphics system.
2319
2321{
2323 TColor *color = gROOT->GetColor(ci);
2324 if (color)
2325 return color->GetPixel();
2326 else
2327 ::Warning("TColor::Number2Pixel", "color with index %d not defined", ci);
2328
2329 return 0;
2330}
2331
2332////////////////////////////////////////////////////////////////////////////////
2333/// Convert r,g,b to graphics system dependent pixel value.
2334/// The r,g,b triplet must be [0,1].
2335
2337{
2338 if (r < 0) r = 0;
2339 if (g < 0) g = 0;
2340 if (b < 0) b = 0;
2341 if (r > 1) r = 1;
2342 if (g > 1) g = 1;
2343 if (b > 1) b = 1;
2344
2345 ColorStruct_t color;
2346 color.fRed = UShort_t(r * 65535);
2347 color.fGreen = UShort_t(g * 65535);
2348 color.fBlue = UShort_t(b * 65535);
2349 color.fMask = kDoRed | kDoGreen | kDoBlue;
2350 gVirtualX->AllocColor(gVirtualX->GetColormap(), color);
2351 return color.fPixel;
2352}
2353
2354////////////////////////////////////////////////////////////////////////////////
2355/// Convert r,g,b to graphics system dependent pixel value.
2356/// The r,g,b triplet must be [0,255].
2357
2359{
2360 if (r < 0) r = 0;
2361 if (g < 0) g = 0;
2362 if (b < 0) b = 0;
2363 if (r > 255) r = 255;
2364 if (g > 255) g = 255;
2365 if (b > 255) b = 255;
2366
2367 ColorStruct_t color;
2368 color.fRed = UShort_t(r * 257); // 65535/255
2369 color.fGreen = UShort_t(g * 257);
2370 color.fBlue = UShort_t(b * 257);
2371 color.fMask = kDoRed | kDoGreen | kDoBlue;
2372 gVirtualX->AllocColor(gVirtualX->GetColormap(), color);
2373 return color.fPixel;
2374}
2375
2376////////////////////////////////////////////////////////////////////////////////
2377/// Convert machine dependent pixel value (obtained via RGB2Pixel or
2378/// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet.
2379/// The r,g,b triplet will be [0,1].
2380
2382{
2383 ColorStruct_t color;
2384 color.fPixel = pixel;
2385 gVirtualX->QueryColor(gVirtualX->GetColormap(), color);
2386 r = (Float_t)color.fRed / 65535.0f;
2387 g = (Float_t)color.fGreen / 65535.0f;
2388 b = (Float_t)color.fBlue / 65535.0f;
2389}
2390
2391////////////////////////////////////////////////////////////////////////////////
2392/// Convert machine dependent pixel value (obtained via RGB2Pixel or
2393/// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet.
2394/// The r,g,b triplet will be [0,255].
2395
2397{
2398 ColorStruct_t color;
2399 color.fPixel = pixel;
2400 gVirtualX->QueryColor(gVirtualX->GetColormap(), color);
2401 r = color.fRed / 257;
2402 g = color.fGreen / 257;
2403 b = color.fBlue / 257;
2404}
2405
2406////////////////////////////////////////////////////////////////////////////////
2407/// Convert machine dependent pixel value (obtained via RGB2Pixel or
2408/// via Number2Pixel() or via TColor::GetPixel()) to a hexadecimal string.
2409/// This string can be directly passed to, for example,
2410/// TGClient::GetColorByName(). String will be reused so copy immediately
2411/// if needed.
2412
2414{
2415 static TString tempbuf;
2416 Int_t r, g, b;
2417 Pixel2RGB(pixel, r, g, b);
2418 tempbuf.Form("#%02x%02x%02x", r, g, b);
2419 return tempbuf;
2420}
2421
2422////////////////////////////////////////////////////////////////////////////////
2423/// Save a color with index > 228 as a C++ statement(s) on output stream out.
2424/// Return kFALSE if color not saved in the output stream
2425
2426Bool_t TColor::SaveColor(std::ostream &out, Int_t ci)
2427{
2428 if (ci <= 228)
2429 return kFALSE;
2430
2431 char quote = '"';
2432
2433 TColor *c = gROOT->GetColor(ci);
2434 if (!c)
2435 return kFALSE;
2436
2437 if (gROOT->ClassSaved(TColor::Class())) {
2438 out << std::endl;
2439 } else {
2440 out << std::endl;
2441 out << " Int_t ci; // for color index setting" << std::endl;
2442 out << " TColor *color; // for color definition with alpha" << std::endl;
2443 }
2444
2445 Float_t r, g, b, a;
2446
2447 c->GetRGB(r, g, b);
2448 a = c->GetAlpha();
2449
2450 if (a < 1.) {
2451 out<<" ci = "<<ci<<";"<<std::endl;
2452 out<<" color = new TColor(ci, "<<r<<", "<<g<<", "<<b<<", "
2453 <<"\" \", "<<a<<");"<<std::endl;
2454 } else {
2455 Int_t ri = (Int_t)(255*r),
2456 gi = (Int_t)(255*g),
2457 bi = (Int_t)(255*b);
2458 TString cname = TString::Format("#%02x%02x%02x", ri, gi, bi);
2459 out<<" ci = TColor::GetColor("<<quote<<cname.Data()<<quote<<");"<<std::endl;
2460 }
2461
2462 return kTRUE;
2463}
2464
2465////////////////////////////////////////////////////////////////////////////////
2466/// Return whether all colors return grayscale values.
2468{
2469 return fgGrayscaleMode;
2470}
2471
2472////////////////////////////////////////////////////////////////////////////////
2473/// Set whether all colors should return grayscale values.
2474
2475void TColor::SetGrayscale(Bool_t set /*= kTRUE*/)
2476{
2477 if (fgGrayscaleMode == set) return;
2478
2479 fgGrayscaleMode = set;
2480
2481 if (!gVirtualX || gROOT->IsBatch()) return;
2482
2484 TIter iColor(gROOT->GetListOfColors());
2485 TColor* color = nullptr;
2486 while ((color = (TColor*) iColor()))
2487 color->Allocate();
2488}
2489
2490////////////////////////////////////////////////////////////////////////////////
2491/// \brief Static function creating a color palette based on an input text file.
2492///
2493/// Every color in the file will take the same amount of space in the palette.
2494///
2495/// \see https://doi.org/10.1038/s41467-020-19160-7
2496/// \note This function is designed to load into ROOT the colour-vision
2497/// deficiency friendly and perceptually uniform colour maps specially designed
2498/// in https://doi.org/10.5281/zenodo.4491293, namely the .txt files stored
2499/// in the subfolders of ScientificColourMaps7.zip, e.g. batlow/batlow.txt
2500///
2501/// \param fileName: Name of a .txt file (ASCII) containing three floats per
2502/// line, separated by spaces, namely the r g b fractions of the color, each
2503/// value being in the range [0,1].
2504/// \param alpha the global opacity for all colors within this palette
2505/// \return a positive value on success and -1 on error.
2506/// \author Fernando Hueso-González
2508{
2509 std::ifstream f(fileName.Data());
2510 if (!f.good()) {
2511 ::Error("TColor::CreateColorPalette(const TString)", "%s does not exist or cannot be opened", fileName.Data());
2512 return -1;
2513 }
2514
2515 Int_t nLines = 0;
2516 Float_t r, g, b;
2517 std::vector<Float_t> reds, greens, blues;
2518 while (f >> r >> g >> b) {
2519 nLines++;
2520 if (r < 0. || r > 1.) {
2521 ::Error("TColor::CreateColorPalette(const TString)", "Red value %f outside [0,1] on line %d of %s ", r,
2522 nLines, fileName.Data());
2523 f.close();
2524 return -1;
2525 }
2526 if (g < 0. || g > 1.) {
2527 ::Error("TColor::CreateColorPalette(const TString)", "Green value %f outside [0,1] on line %d of %s ", g,
2528 nLines, fileName.Data());
2529 f.close();
2530 return -1;
2531 }
2532 if (b < 0. || b > 1.) {
2533 ::Error("TColor::CreateColorPalette(const TString)", "Blue value %f outside [0,1] on line %d of %s ", b,
2534 nLines, fileName.Data());
2535 f.close();
2536 return -1;
2537 }
2538 reds.emplace_back(r);
2539 greens.emplace_back(g);
2540 blues.emplace_back(b);
2541 }
2542 f.close();
2543 if (nLines < 2) {
2544 ::Error("TColor::CreateColorPalette(const TString)", "Found insufficient color lines (%d) on %s", nLines,
2545 fileName.Data());
2546 return -1;
2547 }
2548
2550 Int_t *palette = new Int_t[nLines];
2551
2552 for (Int_t i = 0; i < nLines; ++i) {
2553 new TColor(reds.at(i), greens.at(i), blues.at(i), alpha);
2554 palette[i] = gHighestColorIndex;
2555 }
2556 TColor::SetPalette(nLines, palette);
2557 delete[] palette;
2558 return gHighestColorIndex + 1 - nLines;
2559}
2560
2561////////////////////////////////////////////////////////////////////////////////
2562/// Static function creating a color table with several connected linear gradients.
2563///
2564/// - Number: The number of end point colors that will form the gradients.
2565/// Must be at least 2.
2566/// - Stops: Where in the whole table the end point colors should lie.
2567/// Each entry must be on [0, 1], each entry must be greater than
2568/// the previous entry.
2569/// - Red, Green, Blue: The end point color values.
2570/// Each entry must be on [0, 1]
2571/// - NColors: Total number of colors in the table. Must be at least 1.
2572/// - alpha: the opacity factor, between 0 and 1. Default is no transparency (1).
2573/// - setPalette: activate the newly created palette (true by default). If false,
2574/// the caller is in charge of calling TColor::SetPalette using the
2575/// return value of the function (first palette color index) and
2576/// reconstructing the Int_t palette[NColors+1] array.
2577///
2578/// Returns a positive value (the index of the first color of the palette) on
2579/// success and -1 on error.
2580///
2581/// The table is constructed by tracing lines between the given points in
2582/// RGB space. Each color value may have a value between 0 and 1. The
2583/// difference between consecutive "Stops" values gives the fraction of
2584/// space in the whole table that should be used for the interval between
2585/// the corresponding color values.
2586///
2587/// Normally the first element of Stops should be 0 and the last should be 1.
2588/// If this is not true, fewer than NColors will be used in proportion with
2589/// the total interval between the first and last elements of Stops.
2590///
2591/// This definition is similar to the povray-definition of gradient
2592/// color tables.
2593///
2594/// For instance:
2595/// ~~~ {.cpp}
2596/// UInt_t Number = 3;
2597/// Double_t Red[3] = { 0.0, 1.0, 1.0 };
2598/// Double_t Green[3] = { 0.0, 0.0, 1.0 };
2599/// Double_t Blue[3] = { 1.0, 0.0, 1.0 };
2600/// Double_t Stops[3] = { 0.0, 0.4, 1.0 };
2601/// ~~~
2602/// This defines a table in which there are three color end points:
2603/// RGB = {0, 0, 1}, {1, 0, 0}, and {1, 1, 1} = blue, red, white
2604/// The first 40% of the table is used to go linearly from blue to red.
2605/// The remaining 60% of the table is used to go linearly from red to white.
2606///
2607/// If you define a very short interval such that less than one color fits
2608/// in it, no colors at all will be allocated. If this occurs for all
2609/// intervals, ROOT will revert to the default palette.
2610///
2611/// Original code by Andreas Zoglauer (zog@mpe.mpg.de)
2612
2614 Double_t* Red, Double_t* Green,
2615 Double_t* Blue, UInt_t NColors, Float_t alpha,
2616 Bool_t setPalette)
2617{
2619
2620 UInt_t g, c;
2621 UInt_t nPalette = 0;
2622 Int_t *palette = new Int_t[NColors+1];
2623 UInt_t nColorsGradient;
2624
2625 if(Number < 2 || NColors < 1){
2626 delete [] palette;
2627 return -1;
2628 }
2629
2630 // Check if all RGB values are between 0.0 and 1.0 and
2631 // Stops goes from 0.0 to 1.0 in increasing order.
2632 for (c = 0; c < Number; c++) {
2633 if (Red[c] < 0 || Red[c] > 1.0 ||
2634 Green[c] < 0 || Green[c] > 1.0 ||
2635 Blue[c] < 0 || Blue[c] > 1.0 ||
2636 Stops[c] < 0 || Stops[c] > 1.0) {
2637 delete [] palette;
2638 return -1;
2639 }
2640 if (c >= 1) {
2641 if (Stops[c-1] > Stops[c]) {
2642 delete [] palette;
2643 return -1;
2644 }
2645 }
2646 }
2647
2648 // Now create the colors and add them to the default palette:
2649
2650 // For each defined gradient...
2651 for (g = 1; g < Number; g++) {
2652 // create the colors...
2653 nColorsGradient = (Int_t) (floor(NColors*Stops[g]) - floor(NColors*Stops[g-1]));
2654 for (c = 0; c < nColorsGradient; c++) {
2655 new TColor( Float_t(Red[g-1] + c * (Red[g] - Red[g-1]) / nColorsGradient),
2656 Float_t(Green[g-1] + c * (Green[g] - Green[g-1])/ nColorsGradient),
2657 Float_t(Blue[g-1] + c * (Blue[g] - Blue[g-1]) / nColorsGradient),
2658 alpha);
2659 palette[nPalette] = gHighestColorIndex;
2660 nPalette++;
2661 }
2662 }
2663
2664 if (setPalette)
2665 TColor::SetPalette(nPalette, palette);
2666 delete [] palette;
2667 return gHighestColorIndex + 1 - NColors;
2668}
2669
2670
2671////////////////////////////////////////////////////////////////////////////////
2672/// Static function.
2673/// The color palette is used by the histogram classes
2674/// (see TH1::Draw options).
2675/// For example TH1::Draw("col") draws a 2-D histogram with cells
2676/// represented by a box filled with a color CI function of the cell content.
2677/// if the cell content is N, the color CI used will be the color number
2678/// in colors[N],etc. If the maximum cell content is > ncolors, all
2679/// cell contents are scaled to ncolors.
2680///
2681/// `if ncolors <= 0` a default palette (see below) of 50 colors is
2682/// defined. The colors defined in this palette are OK for coloring pads, labels.
2683///
2684/// ~~~ {.cpp}
2685/// index 0->9 : grey colors from light to dark grey
2686/// index 10->19 : "brown" colors
2687/// index 20->29 : "blueish" colors
2688/// index 30->39 : "redish" colors
2689/// index 40->49 : basic colors
2690/// ~~~
2691///
2692/// `if ncolors == 1 && colors == 0`, a Rainbow Color map is created
2693/// with 50 colors. It is kept for backward compatibility. Better palettes like
2694/// kBird are recommended.
2695///
2696/// High quality predefined palettes with 255 colors are available when `colors == 0`.
2697/// The following value of `ncolors` give access to:
2698///
2699/// ~~~ {.cpp}
2700/// if ncolors = 51 and colors=0, a Deep Sea palette is used.
2701/// if ncolors = 52 and colors=0, a Grey Scale palette is used.
2702/// if ncolors = 53 and colors=0, a Dark Body Radiator palette is used.
2703/// if ncolors = 54 and colors=0, a Two-Color Hue palette is used.(dark blue through neutral gray to bright yellow)
2704/// if ncolors = 55 and colors=0, a Rain Bow palette is used.
2705/// if ncolors = 56 and colors=0, an Inverted Dark Body Radiator palette is used.
2706/// if ncolors = 57 and colors=0, a monotonically increasing L value palette is used.
2707/// if ncolors = 58 and colors=0, a Cubehelix palette is used
2708/// (Cf. Dave Green's "cubehelix" colour scheme at http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/)
2709/// if ncolors = 59 and colors=0, a Green Red Violet palette is used.
2710/// if ncolors = 60 and colors=0, a Blue Red Yellow palette is used.
2711/// if ncolors = 61 and colors=0, an Ocean palette is used.
2712/// if ncolors = 62 and colors=0, a Color Printable On Grey palette is used.
2713/// if ncolors = 63 and colors=0, an Alpine palette is used.
2714/// if ncolors = 64 and colors=0, an Aquamarine palette is used.
2715/// if ncolors = 65 and colors=0, an Army palette is used.
2716/// if ncolors = 66 and colors=0, an Atlantic palette is used.
2717/// if ncolors = 67 and colors=0, an Aurora palette is used.
2718/// if ncolors = 68 and colors=0, an Avocado palette is used.
2719/// if ncolors = 69 and colors=0, a Beach palette is used.
2720/// if ncolors = 70 and colors=0, a Black Body palette is used.
2721/// if ncolors = 71 and colors=0, a Blue Green Yellow palette is used.
2722/// if ncolors = 72 and colors=0, a Brown Cyan palette is used.
2723/// if ncolors = 73 and colors=0, a CMYK palette is used.
2724/// if ncolors = 74 and colors=0, a Candy palette is used.
2725/// if ncolors = 75 and colors=0, a Cherry palette is used.
2726/// if ncolors = 76 and colors=0, a Coffee palette is used.
2727/// if ncolors = 77 and colors=0, a Dark Rain Bow palette is used.
2728/// if ncolors = 78 and colors=0, a Dark Terrain palette is used.
2729/// if ncolors = 79 and colors=0, a Fall palette is used.
2730/// if ncolors = 80 and colors=0, a Fruit Punch palette is used.
2731/// if ncolors = 81 and colors=0, a Fuchsia palette is used.
2732/// if ncolors = 82 and colors=0, a Grey Yellow palette is used.
2733/// if ncolors = 83 and colors=0, a Green Brown Terrain palette is used.
2734/// if ncolors = 84 and colors=0, a Green Pink palette is used.
2735/// if ncolors = 85 and colors=0, an Island palette is used.
2736/// if ncolors = 86 and colors=0, a Lake palette is used.
2737/// if ncolors = 87 and colors=0, a Light Temperature palette is used.
2738/// if ncolors = 88 and colors=0, a Light Terrain palette is used.
2739/// if ncolors = 89 and colors=0, a Mint palette is used.
2740/// if ncolors = 90 and colors=0, a Neon palette is used.
2741/// if ncolors = 91 and colors=0, a Pastel palette is used.
2742/// if ncolors = 92 and colors=0, a Pearl palette is used.
2743/// if ncolors = 93 and colors=0, a Pigeon palette is used.
2744/// if ncolors = 94 and colors=0, a Plum palette is used.
2745/// if ncolors = 95 and colors=0, a Red Blue palette is used.
2746/// if ncolors = 96 and colors=0, a Rose palette is used.
2747/// if ncolors = 97 and colors=0, a Rust palette is used.
2748/// if ncolors = 98 and colors=0, a Sandy Terrain palette is used.
2749/// if ncolors = 99 and colors=0, a Sienna palette is used.
2750/// if ncolors = 100 and colors=0, a Solar palette is used.
2751/// if ncolors = 101 and colors=0, a South West palette is used.
2752/// if ncolors = 102 and colors=0, a Starry Night palette is used.
2753/// if ncolors = 103 and colors=0, a Sunset palette is used.
2754/// if ncolors = 104 and colors=0, a Temperature Map palette is used.
2755/// if ncolors = 105 and colors=0, a Thermometer palette is used.
2756/// if ncolors = 106 and colors=0, a Valentine palette is used.
2757/// if ncolors = 107 and colors=0, a Visible Spectrum palette is used.
2758/// if ncolors = 108 and colors=0, a Water Melon palette is used.
2759/// if ncolors = 109 and colors=0, a Cool palette is used.
2760/// if ncolors = 110 and colors=0, a Copper palette is used.
2761/// if ncolors = 111 and colors=0, a Gist Earth palette is used.
2762/// if ncolors = 112 and colors=0, a Viridis palette is used.
2763/// if ncolors = 113 and colors=0, a Cividis palette is used.
2764/// ~~~
2765/// These palettes can also be accessed by names:
2766/// ~~~ {.cpp}
2767/// kDeepSea=51, kGreyScale=52, kDarkBodyRadiator=53,
2768/// kBlueYellow= 54, kRainBow=55, kInvertedDarkBodyRadiator=56,
2769/// kBird=57, kCubehelix=58, kGreenRedViolet=59,
2770/// kBlueRedYellow=60, kOcean=61, kColorPrintableOnGrey=62,
2771/// kAlpine=63, kAquamarine=64, kArmy=65,
2772/// kAtlantic=66, kAurora=67, kAvocado=68,
2773/// kBeach=69, kBlackBody=70, kBlueGreenYellow=71,
2774/// kBrownCyan=72, kCMYK=73, kCandy=74,
2775/// kCherry=75, kCoffee=76, kDarkRainBow=77,
2776/// kDarkTerrain=78, kFall=79, kFruitPunch=80,
2777/// kFuchsia=81, kGreyYellow=82, kGreenBrownTerrain=83,
2778/// kGreenPink=84, kIsland=85, kLake=86,
2779/// kLightTemperature=87, kLightTerrain=88, kMint=89,
2780/// kNeon=90, kPastel=91, kPearl=92,
2781/// kPigeon=93, kPlum=94, kRedBlue=95,
2782/// kRose=96, kRust=97, kSandyTerrain=98,
2783/// kSienna=99, kSolar=100, kSouthWest=101,
2784/// kStarryNight=102, kSunset=103, kTemperatureMap=104,
2785/// kThermometer=105, kValentine=106, kVisibleSpectrum=107,
2786/// kWaterMelon=108, kCool=109, kCopper=110,
2787/// kGistEarth=111 kViridis=112, kCividis=113
2788/// ~~~
2789/// For example:
2790/// ~~~ {.cpp}
2791/// gStyle->SetPalette(kBird);
2792/// ~~~
2793/// Set the current palette as "Bird" (number 57).
2794///
2795/// The color numbers specified in the palette can be viewed by selecting
2796/// the item "colors" in the "VIEW" menu of the canvas toolbar.
2797/// The color parameters can be changed via TColor::SetRGB.
2798///
2799/// Note that when drawing a 2D histogram `h2` with the option "COL" or
2800/// "COLZ" or with any "CONT" options using the color map, the number of colors
2801/// used is defined by the number of contours `n` specified with:
2802/// `h2->SetContour(n)`
2803
2805{
2806 Int_t i;
2807
2808 static Int_t paletteType = 0;
2809
2810 Int_t palette[50] = {19,18,17,16,15,14,13,12,11,20,
2811 21,22,23,24,25,26,27,28,29,30, 8,
2812 31,32,33,34,35,36,37,38,39,40, 9,
2813 41,42,43,44,45,47,48,49,46,50, 2,
2814 7, 6, 5, 4, 3, 2,1};
2815
2816 // set default palette (pad type)
2817 if (ncolors <= 0) {
2818 ncolors = 50;
2819 fgPalette.Set(ncolors);
2820 for (i=0;i<ncolors;i++) fgPalette.fArray[i] = palette[i];
2821 paletteType = 1;
2822 return;
2823 }
2824
2825 // set Rainbow Color map. Kept for backward compatibility.
2826 if (ncolors == 1 && colors == nullptr) {
2827 ncolors = 50;
2828 fgPalette.Set(ncolors);
2829 for (i=0;i<ncolors-1;i++) fgPalette.fArray[i] = 51+i;
2830 fgPalette.fArray[ncolors-1] = kRed; // the last color of this palette is red
2831 paletteType = 2;
2832 return;
2833 }
2834
2835 // High quality palettes (255 levels)
2836 if (colors == nullptr && ncolors>50) {
2837
2838 if (!fgPalettesList.fN) fgPalettesList.Set(63); // Right now 63 high quality palettes
2839 Int_t Idx = (Int_t)fgPalettesList.fArray[ncolors-51]; // High quality palettes indices start at 51
2840
2841 // This high quality palette has already been created. Reuse it.
2842 if (Idx > 0) {
2843 Double_t alphas = 10*(fgPalettesList.fArray[ncolors-51]-Idx);
2844 Bool_t same_alpha = TMath::Abs(alpha-alphas) < 0.0001;
2845 if (paletteType == ncolors && same_alpha) return; // The current palette is already this one.
2846 fgPalette.Set(255); // High quality palettes have 255 entries
2847 for (i=0;i<255;i++) fgPalette.fArray[i] = Idx+i;
2848 paletteType = ncolors;
2849
2850 // restore the palette transparency if needed
2851 if (alphas>0 && !same_alpha) {
2852 TColor *ca;
2853 for (i=0;i<255;i++) {
2854 ca = gROOT->GetColor(Idx+i);
2855 ca->SetAlpha(alpha);
2856 }
2857 fgPalettesList.fArray[paletteType-51] = (Double_t)Idx+alpha/10.;
2858 }
2859 return;
2860 }
2861
2863 Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
2864
2865 switch (ncolors) {
2866 // Deep Sea
2867 case 51:
2868 {
2869 Double_t red[9] = { 0./255., 9./255., 13./255., 17./255., 24./255., 32./255., 27./255., 25./255., 29./255.};
2870 Double_t green[9] = { 0./255., 0./255., 0./255., 2./255., 37./255., 74./255., 113./255., 160./255., 221./255.};
2871 Double_t blue[9] = { 28./255., 42./255., 59./255., 78./255., 98./255., 129./255., 154./255., 184./255., 221./255.};
2872 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2873 }
2874 break;
2875
2876 // Grey Scale
2877 case 52:
2878 {
2879 Double_t red[9] = { 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.};
2880 Double_t green[9] = { 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.};
2881 Double_t blue[9] = { 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.};
2882 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2883 }
2884 break;
2885
2886 // Dark Body Radiator
2887 case 53:
2888 {
2889 Double_t red[9] = { 0./255., 45./255., 99./255., 156./255., 212./255., 230./255., 237./255., 234./255., 242./255.};
2890 Double_t green[9] = { 0./255., 0./255., 0./255., 45./255., 101./255., 168./255., 238./255., 238./255., 243./255.};
2891 Double_t blue[9] = { 0./255., 1./255., 1./255., 3./255., 9./255., 8./255., 11./255., 95./255., 230./255.};
2892 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2893 }
2894 break;
2895
2896 // Two-color hue (dark blue through neutral gray to bright yellow)
2897 case 54:
2898 {
2899 Double_t red[9] = { 0./255., 22./255., 44./255., 68./255., 93./255., 124./255., 160./255., 192./255., 237./255.};
2900 Double_t green[9] = { 0./255., 16./255., 41./255., 67./255., 93./255., 125./255., 162./255., 194./255., 241./255.};
2901 Double_t blue[9] = { 97./255., 100./255., 99./255., 99./255., 93./255., 68./255., 44./255., 26./255., 74./255.};
2902 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2903 }
2904 break;
2905
2906 // Rain Bow
2907 case 55:
2908 {
2909 Double_t red[9] = { 0./255., 5./255., 15./255., 35./255., 102./255., 196./255., 208./255., 199./255., 110./255.};
2910 Double_t green[9] = { 0./255., 48./255., 124./255., 192./255., 206./255., 226./255., 97./255., 16./255., 0./255.};
2911 Double_t blue[9] = { 99./255., 142./255., 198./255., 201./255., 90./255., 22./255., 13./255., 8./255., 2./255.};
2912 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2913 }
2914 break;
2915
2916 // Inverted Dark Body Radiator
2917 case 56:
2918 {
2919 Double_t red[9] = { 242./255., 234./255., 237./255., 230./255., 212./255., 156./255., 99./255., 45./255., 0./255.};
2920 Double_t green[9] = { 243./255., 238./255., 238./255., 168./255., 101./255., 45./255., 0./255., 0./255., 0./255.};
2921 Double_t blue[9] = { 230./255., 95./255., 11./255., 8./255., 9./255., 3./255., 1./255., 1./255., 0./255.};
2922 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2923 }
2924 break;
2925
2926 // Bird
2927 case 57:
2928 {
2929 Double_t red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764};
2930 Double_t green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832};
2931 Double_t blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539};
2932 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2933 }
2934 break;
2935
2936 // Cubehelix
2937 case 58:
2938 {
2939 Double_t red[9] = { 0.0000, 0.0956, 0.0098, 0.2124, 0.6905, 0.9242, 0.7914, 0.7596, 1.0000};
2940 Double_t green[9] = { 0.0000, 0.1147, 0.3616, 0.5041, 0.4577, 0.4691, 0.6905, 0.9237, 1.0000};
2941 Double_t blue[9] = { 0.0000, 0.2669, 0.3121, 0.1318, 0.2236, 0.6741, 0.9882, 0.9593, 1.0000};
2942 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2943 }
2944 break;
2945
2946 // Green Red Violet
2947 case 59:
2948 {
2949 Double_t red[9] = {13./255., 23./255., 25./255., 63./255., 76./255., 104./255., 137./255., 161./255., 206./255.};
2950 Double_t green[9] = {95./255., 67./255., 37./255., 21./255., 0./255., 12./255., 35./255., 52./255., 79./255.};
2951 Double_t blue[9] = { 4./255., 3./255., 2./255., 6./255., 11./255., 22./255., 49./255., 98./255., 208./255.};
2952 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2953 }
2954 break;
2955
2956 // Blue Red Yellow
2957 case 60:
2958 {
2959 Double_t red[9] = {0./255., 61./255., 89./255., 122./255., 143./255., 160./255., 185./255., 204./255., 231./255.};
2960 Double_t green[9] = {0./255., 0./255., 0./255., 0./255., 14./255., 37./255., 72./255., 132./255., 235./255.};
2961 Double_t blue[9] = {0./255., 140./255., 224./255., 144./255., 4./255., 5./255., 6./255., 9./255., 13./255.};
2962 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2963 }
2964 break;
2965
2966 // Ocean
2967 case 61:
2968 {
2969 Double_t red[9] = { 14./255., 7./255., 2./255., 0./255., 5./255., 11./255., 55./255., 131./255., 229./255.};
2970 Double_t green[9] = {105./255., 56./255., 26./255., 1./255., 42./255., 74./255., 131./255., 171./255., 229./255.};
2971 Double_t blue[9] = { 2./255., 21./255., 35./255., 60./255., 92./255., 113./255., 160./255., 185./255., 229./255.};
2972 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2973 }
2974 break;
2975
2976 // Color Printable On Grey
2977 case 62:
2978 {
2979 Double_t red[9] = { 0./255., 0./255., 0./255., 70./255., 148./255., 231./255., 235./255., 237./255., 244./255.};
2980 Double_t green[9] = { 0./255., 0./255., 0./255., 0./255., 0./255., 69./255., 67./255., 216./255., 244./255.};
2981 Double_t blue[9] = { 0./255., 102./255., 228./255., 231./255., 177./255., 124./255., 137./255., 20./255., 244./255.};
2982 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2983 }
2984 break;
2985
2986 // Alpine
2987 case 63:
2988 {
2989 Double_t red[9] = { 50./255., 56./255., 63./255., 68./255., 93./255., 121./255., 165./255., 192./255., 241./255.};
2990 Double_t green[9] = { 66./255., 81./255., 91./255., 96./255., 111./255., 128./255., 155./255., 189./255., 241./255.};
2991 Double_t blue[9] = { 97./255., 91./255., 75./255., 65./255., 77./255., 103./255., 143./255., 167./255., 217./255.};
2992 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
2993 }
2994 break;
2995
2996 // Aquamarine
2997 case 64:
2998 {
2999 Double_t red[9] = { 145./255., 166./255., 167./255., 156./255., 131./255., 114./255., 101./255., 112./255., 132./255.};
3000 Double_t green[9] = { 158./255., 178./255., 179./255., 181./255., 163./255., 154./255., 144./255., 152./255., 159./255.};
3001 Double_t blue[9] = { 190./255., 199./255., 201./255., 192./255., 176./255., 169./255., 160./255., 166./255., 190./255.};
3002 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3003 }
3004 break;
3005
3006 // Army
3007 case 65:
3008 {
3009 Double_t red[9] = { 93./255., 91./255., 99./255., 108./255., 130./255., 125./255., 132./255., 155./255., 174./255.};
3010 Double_t green[9] = { 126./255., 124./255., 128./255., 129./255., 131./255., 121./255., 119./255., 153./255., 173./255.};
3011 Double_t blue[9] = { 103./255., 94./255., 87./255., 85./255., 80./255., 85./255., 107./255., 120./255., 146./255.};
3012 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3013 }
3014 break;
3015
3016 // Atlantic
3017 case 66:
3018 {
3019 Double_t red[9] = { 24./255., 40./255., 69./255., 90./255., 104./255., 114./255., 120./255., 132./255., 103./255.};
3020 Double_t green[9] = { 29./255., 52./255., 94./255., 127./255., 150./255., 162./255., 159./255., 151./255., 101./255.};
3021 Double_t blue[9] = { 29./255., 52./255., 96./255., 132./255., 162./255., 181./255., 184./255., 186./255., 131./255.};
3022 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3023 }
3024 break;
3025
3026 // Aurora
3027 case 67:
3028 {
3029 Double_t red[9] = { 46./255., 38./255., 61./255., 92./255., 113./255., 121./255., 132./255., 150./255., 191./255.};
3030 Double_t green[9] = { 46./255., 36./255., 40./255., 69./255., 110./255., 135./255., 131./255., 92./255., 34./255.};
3031 Double_t blue[9] = { 46./255., 80./255., 74./255., 70./255., 81./255., 105./255., 165./255., 211./255., 225./255.};
3032 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3033 }
3034 break;
3035
3036 // Avocado
3037 case 68:
3038 {
3039 Double_t red[9] = { 0./255., 4./255., 12./255., 30./255., 52./255., 101./255., 142./255., 190./255., 237./255.};
3040 Double_t green[9] = { 0./255., 40./255., 86./255., 121./255., 140./255., 172./255., 187./255., 213./255., 240./255.};
3041 Double_t blue[9] = { 0./255., 9./255., 14./255., 18./255., 21./255., 23./255., 27./255., 35./255., 101./255.};
3042 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3043 }
3044 break;
3045
3046 // Beach
3047 case 69:
3048 {
3049 Double_t red[9] = { 198./255., 206./255., 206./255., 211./255., 198./255., 181./255., 161./255., 171./255., 244./255.};
3050 Double_t green[9] = { 103./255., 133./255., 150./255., 172./255., 178./255., 174./255., 163./255., 175./255., 244./255.};
3051 Double_t blue[9] = { 49./255., 54./255., 55./255., 66./255., 91./255., 130./255., 184./255., 224./255., 244./255.};
3052 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3053 }
3054 break;
3055
3056 // Black Body
3057 case 70:
3058 {
3059 Double_t red[9] = { 243./255., 243./255., 240./255., 240./255., 241./255., 239./255., 186./255., 151./255., 129./255.};
3060 Double_t green[9] = { 0./255., 46./255., 99./255., 149./255., 194./255., 220./255., 183./255., 166./255., 147./255.};
3061 Double_t blue[9] = { 6./255., 8./255., 36./255., 91./255., 169./255., 235./255., 246./255., 240./255., 233./255.};
3062 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3063 }
3064 break;
3065
3066 // Blue Green Yellow
3067 case 71:
3068 {
3069 Double_t red[9] = { 22./255., 19./255., 19./255., 25./255., 35./255., 53./255., 88./255., 139./255., 210./255.};
3070 Double_t green[9] = { 0./255., 32./255., 69./255., 108./255., 135./255., 159./255., 183./255., 198./255., 215./255.};
3071 Double_t blue[9] = { 77./255., 96./255., 110./255., 116./255., 110./255., 100./255., 90./255., 78./255., 70./255.};
3072 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3073 }
3074 break;
3075
3076 // Brown Cyan
3077 case 72:
3078 {
3079 Double_t red[9] = { 68./255., 116./255., 165./255., 182./255., 189./255., 180./255., 145./255., 111./255., 71./255.};
3080 Double_t green[9] = { 37./255., 82./255., 135./255., 178./255., 204./255., 225./255., 221./255., 202./255., 147./255.};
3081 Double_t blue[9] = { 16./255., 55./255., 105./255., 147./255., 196./255., 226./255., 232./255., 224./255., 178./255.};
3082 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3083 }
3084 break;
3085
3086 // CMYK
3087 case 73:
3088 {
3089 Double_t red[9] = { 61./255., 99./255., 136./255., 181./255., 213./255., 225./255., 198./255., 136./255., 24./255.};
3090 Double_t green[9] = { 149./255., 140./255., 96./255., 83./255., 132./255., 178./255., 190./255., 135./255., 22./255.};
3091 Double_t blue[9] = { 214./255., 203./255., 168./255., 135./255., 110./255., 100./255., 111./255., 113./255., 22./255.};
3092 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3093 }
3094 break;
3095
3096 // Candy
3097 case 74:
3098 {
3099 Double_t red[9] = { 76./255., 120./255., 156./255., 183./255., 197./255., 180./255., 162./255., 154./255., 140./255.};
3100 Double_t green[9] = { 34./255., 35./255., 42./255., 69./255., 102./255., 137./255., 164./255., 188./255., 197./255.};
3101 Double_t blue[9] = { 64./255., 69./255., 78./255., 105./255., 142./255., 177./255., 205./255., 217./255., 198./255.};
3102 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3103 }
3104 break;
3105
3106 // Cherry
3107 case 75:
3108 {
3109 Double_t red[9] = { 37./255., 102./255., 157./255., 188./255., 196./255., 214./255., 223./255., 235./255., 251./255.};
3110 Double_t green[9] = { 37./255., 29./255., 25./255., 37./255., 67./255., 91./255., 132./255., 185./255., 251./255.};
3111 Double_t blue[9] = { 37./255., 32./255., 33./255., 45./255., 66./255., 98./255., 137./255., 187./255., 251./255.};
3112 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3113 }
3114 break;
3115
3116 // Coffee
3117 case 76:
3118 {
3119 Double_t red[9] = { 79./255., 100./255., 119./255., 137./255., 153./255., 172./255., 192./255., 205./255., 250./255.};
3120 Double_t green[9] = { 63./255., 79./255., 93./255., 103./255., 115./255., 135./255., 167./255., 196./255., 250./255.};
3121 Double_t blue[9] = { 51./255., 59./255., 66./255., 61./255., 62./255., 70./255., 110./255., 160./255., 250./255.};
3122 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3123 }
3124 break;
3125
3126 // Dark Rain Bow
3127 case 77:
3128 {
3129 Double_t red[9] = { 43./255., 44./255., 50./255., 66./255., 125./255., 172./255., 178./255., 155./255., 157./255.};
3130 Double_t green[9] = { 63./255., 63./255., 85./255., 101./255., 138./255., 163./255., 122./255., 51./255., 39./255.};
3131 Double_t blue[9] = { 121./255., 101./255., 58./255., 44./255., 47./255., 55./255., 57./255., 44./255., 43./255.};
3132 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3133 }
3134 break;
3135
3136 // Dark Terrain
3137 case 78:
3138 {
3139 Double_t red[9] = { 0./255., 41./255., 62./255., 79./255., 90./255., 87./255., 99./255., 140./255., 228./255.};
3140 Double_t green[9] = { 0./255., 57./255., 81./255., 93./255., 85./255., 70./255., 71./255., 125./255., 228./255.};
3141 Double_t blue[9] = { 95./255., 91./255., 91./255., 82./255., 60./255., 43./255., 44./255., 112./255., 228./255.};
3142 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3143 }
3144 break;
3145
3146 // Fall
3147 case 79:
3148 {
3149 Double_t red[9] = { 49./255., 59./255., 72./255., 88./255., 114./255., 141./255., 176./255., 205./255., 222./255.};
3150 Double_t green[9] = { 78./255., 72./255., 66./255., 57./255., 59./255., 75./255., 106./255., 142./255., 173./255.};
3151 Double_t blue[9] = { 78./255., 55./255., 46./255., 40./255., 39./255., 39./255., 40./255., 41./255., 47./255.};
3152 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3153 }
3154 break;
3155
3156 // Fruit Punch
3157 case 80:
3158 {
3159 Double_t red[9] = { 243./255., 222./255., 201./255., 185./255., 165./255., 158./255., 166./255., 187./255., 219./255.};
3160 Double_t green[9] = { 94./255., 108./255., 132./255., 135./255., 125./255., 96./255., 68./255., 51./255., 61./255.};
3161 Double_t blue[9] = { 7./255., 9./255., 12./255., 19./255., 45./255., 89./255., 118./255., 146./255., 118./255.};
3162 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3163 }
3164 break;
3165
3166 // Fuchsia
3167 case 81:
3168 {
3169 Double_t red[9] = { 19./255., 44./255., 74./255., 105./255., 137./255., 166./255., 194./255., 206./255., 220./255.};
3170 Double_t green[9] = { 19./255., 28./255., 40./255., 55./255., 82./255., 110./255., 159./255., 181./255., 220./255.};
3171 Double_t blue[9] = { 19./255., 42./255., 68./255., 96./255., 129./255., 157./255., 188./255., 203./255., 220./255.};
3172 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3173 }
3174 break;
3175
3176 // Grey Yellow
3177 case 82:
3178 {
3179 Double_t red[9] = { 33./255., 44./255., 70./255., 99./255., 140./255., 165./255., 199./255., 211./255., 216./255.};
3180 Double_t green[9] = { 38./255., 50./255., 76./255., 105./255., 140./255., 165./255., 191./255., 189./255., 167./255.};
3181 Double_t blue[9] = { 55./255., 67./255., 97./255., 124./255., 140./255., 166./255., 163./255., 129./255., 52./255.};
3182 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3183 }
3184 break;
3185
3186 // Green Brown Terrain
3187 case 83:
3188 {
3189 Double_t red[9] = { 0./255., 33./255., 73./255., 124./255., 136./255., 152./255., 159./255., 171./255., 223./255.};
3190 Double_t green[9] = { 0./255., 43./255., 92./255., 124./255., 134./255., 126./255., 121./255., 144./255., 223./255.};
3191 Double_t blue[9] = { 0./255., 43./255., 68./255., 76./255., 73./255., 64./255., 72./255., 114./255., 223./255.};
3192 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3193 }
3194 break;
3195
3196 // Green Pink
3197 case 84:
3198 {
3199 Double_t red[9] = { 5./255., 18./255., 45./255., 124./255., 193./255., 223./255., 205./255., 128./255., 49./255.};
3200 Double_t green[9] = { 48./255., 134./255., 207./255., 230./255., 193./255., 113./255., 28./255., 0./255., 7./255.};
3201 Double_t blue[9] = { 6./255., 15./255., 41./255., 121./255., 193./255., 226./255., 208./255., 130./255., 49./255.};
3202 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3203 }
3204 break;
3205
3206 // Island
3207 case 85:
3208 {
3209 Double_t red[9] = { 180./255., 106./255., 104./255., 135./255., 164./255., 188./255., 189./255., 165./255., 144./255.};
3210 Double_t green[9] = { 72./255., 126./255., 154./255., 184./255., 198./255., 207./255., 205./255., 190./255., 179./255.};
3211 Double_t blue[9] = { 41./255., 120./255., 158./255., 188./255., 194./255., 181./255., 145./255., 100./255., 62./255.};
3212 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3213 }
3214 break;
3215
3216 // Lake
3217 case 86:
3218 {
3219 Double_t red[9] = { 57./255., 72./255., 94./255., 117./255., 136./255., 154./255., 174./255., 192./255., 215./255.};
3220 Double_t green[9] = { 0./255., 33./255., 68./255., 109./255., 140./255., 171./255., 192./255., 196./255., 209./255.};
3221 Double_t blue[9] = { 116./255., 137./255., 173./255., 201./255., 200./255., 201./255., 203./255., 190./255., 187./255.};
3222 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3223 }
3224 break;
3225
3226 // Light Temperature
3227 case 87:
3228 {
3229 Double_t red[9] = { 31./255., 71./255., 123./255., 160./255., 210./255., 222./255., 214./255., 199./255., 183./255.};
3230 Double_t green[9] = { 40./255., 117./255., 171./255., 211./255., 231./255., 220./255., 190./255., 132./255., 65./255.};
3231 Double_t blue[9] = { 234./255., 214./255., 228./255., 222./255., 210./255., 160./255., 105./255., 60./255., 34./255.};
3232 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3233 }
3234 break;
3235
3236 // Light Terrain
3237 case 88:
3238 {
3239 Double_t red[9] = { 123./255., 108./255., 109./255., 126./255., 154./255., 172./255., 188./255., 196./255., 218./255.};
3240 Double_t green[9] = { 184./255., 138./255., 130./255., 133./255., 154./255., 175./255., 188./255., 196./255., 218./255.};
3241 Double_t blue[9] = { 208./255., 130./255., 109./255., 99./255., 110./255., 122./255., 150./255., 171./255., 218./255.};
3242 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3243 }
3244 break;
3245
3246 // Mint
3247 case 89:
3248 {
3249 Double_t red[9] = { 105./255., 106./255., 122./255., 143./255., 159./255., 172./255., 176./255., 181./255., 207./255.};
3250 Double_t green[9] = { 252./255., 197./255., 194./255., 187./255., 174./255., 162./255., 153./255., 136./255., 125./255.};
3251 Double_t blue[9] = { 146./255., 133./255., 144./255., 155./255., 163./255., 167./255., 166./255., 162./255., 174./255.};
3252 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3253 }
3254 break;
3255
3256 // Neon
3257 case 90:
3258 {
3259 Double_t red[9] = { 171./255., 141./255., 145./255., 152./255., 154./255., 159./255., 163./255., 158./255., 177./255.};
3260 Double_t green[9] = { 236./255., 143./255., 100./255., 63./255., 53./255., 55./255., 44./255., 31./255., 6./255.};
3261 Double_t blue[9] = { 59./255., 48./255., 46./255., 44./255., 42./255., 54./255., 82./255., 112./255., 179./255.};
3262 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3263 }
3264 break;
3265
3266 // Pastel
3267 case 91:
3268 {
3269 Double_t red[9] = { 180./255., 190./255., 209./255., 223./255., 204./255., 228./255., 205./255., 152./255., 91./255.};
3270 Double_t green[9] = { 93./255., 125./255., 147./255., 172./255., 181./255., 224./255., 233./255., 198./255., 158./255.};
3271 Double_t blue[9] = { 236./255., 218./255., 160./255., 133./255., 114./255., 132./255., 162./255., 220./255., 218./255.};
3272 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3273 }
3274 break;
3275
3276 // Pearl
3277 case 92:
3278 {
3279 Double_t red[9] = { 225./255., 183./255., 162./255., 135./255., 115./255., 111./255., 119./255., 145./255., 211./255.};
3280 Double_t green[9] = { 205./255., 177./255., 166./255., 135./255., 124./255., 117./255., 117./255., 132./255., 172./255.};
3281 Double_t blue[9] = { 186./255., 165./255., 155./255., 135./255., 126./255., 130./255., 150./255., 178./255., 226./255.};
3282 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3283 }
3284 break;
3285
3286 // Pigeon
3287 case 93:
3288 {
3289 Double_t red[9] = { 39./255., 43./255., 59./255., 63./255., 80./255., 116./255., 153./255., 177./255., 223./255.};
3290 Double_t green[9] = { 39./255., 43./255., 59./255., 74./255., 91./255., 114./255., 139./255., 165./255., 223./255.};
3291 Double_t blue[9] = { 39./255., 50./255., 59./255., 70./255., 85./255., 115./255., 151./255., 176./255., 223./255.};
3292 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3293 }
3294 break;
3295
3296 // Plum
3297 case 94:
3298 {
3299 Double_t red[9] = { 0./255., 38./255., 60./255., 76./255., 84./255., 89./255., 101./255., 128./255., 204./255.};
3300 Double_t green[9] = { 0./255., 10./255., 15./255., 23./255., 35./255., 57./255., 83./255., 123./255., 199./255.};
3301 Double_t blue[9] = { 0./255., 11./255., 22./255., 40./255., 63./255., 86./255., 97./255., 94./255., 85./255.};
3302 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3303 }
3304 break;
3305
3306 // Red Blue
3307 case 95:
3308 {
3309 Double_t red[9] = { 94./255., 112./255., 141./255., 165./255., 167./255., 140./255., 91./255., 49./255., 27./255.};
3310 Double_t green[9] = { 27./255., 46./255., 88./255., 135./255., 166./255., 161./255., 135./255., 97./255., 58./255.};
3311 Double_t blue[9] = { 42./255., 52./255., 81./255., 106./255., 139./255., 158./255., 155./255., 137./255., 116./255.};
3312 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3313 }
3314 break;
3315
3316 // Rose
3317 case 96:
3318 {
3319 Double_t red[9] = { 30./255., 49./255., 79./255., 117./255., 135./255., 151./255., 146./255., 138./255., 147./255.};
3320 Double_t green[9] = { 63./255., 60./255., 72./255., 90./255., 94./255., 94./255., 68./255., 46./255., 16./255.};
3321 Double_t blue[9] = { 18./255., 28./255., 41./255., 56./255., 62./255., 63./255., 50./255., 36./255., 21./255.};
3322 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3323 }
3324 break;
3325
3326 // Rust
3327 case 97:
3328 {
3329 Double_t red[9] = { 0./255., 30./255., 63./255., 101./255., 143./255., 152./255., 169./255., 187./255., 230./255.};
3330 Double_t green[9] = { 0./255., 14./255., 28./255., 42./255., 58./255., 61./255., 67./255., 74./255., 91./255.};
3331 Double_t blue[9] = { 39./255., 26./255., 21./255., 18./255., 15./255., 14./255., 14./255., 13./255., 13./255.};
3332 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3333 }
3334 break;
3335
3336 // Sandy Terrain
3337 case 98:
3338 {
3339 Double_t red[9] = { 149./255., 140./255., 164./255., 179./255., 182./255., 181./255., 131./255., 87./255., 61./255.};
3340 Double_t green[9] = { 62./255., 70./255., 107./255., 136./255., 144./255., 138./255., 117./255., 87./255., 74./255.};
3341 Double_t blue[9] = { 40./255., 38./255., 45./255., 49./255., 49./255., 49./255., 38./255., 32./255., 34./255.};
3342 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3343 }
3344 break;
3345
3346 // Sienna
3347 case 99:
3348 {
3349 Double_t red[9] = { 99./255., 112./255., 148./255., 165./255., 179./255., 182./255., 183./255., 183./255., 208./255.};
3350 Double_t green[9] = { 39./255., 40./255., 57./255., 79./255., 104./255., 127./255., 148./255., 161./255., 198./255.};
3351 Double_t blue[9] = { 15./255., 16./255., 18./255., 33./255., 51./255., 79./255., 103./255., 129./255., 177./255.};
3352 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3353 }
3354 break;
3355
3356 // Solar
3357 case 100:
3358 {
3359 Double_t red[9] = { 99./255., 116./255., 154./255., 174./255., 200./255., 196./255., 201./255., 201./255., 230./255.};
3360 Double_t green[9] = { 0./255., 0./255., 8./255., 32./255., 58./255., 83./255., 119./255., 136./255., 173./255.};
3361 Double_t blue[9] = { 5./255., 6./255., 7./255., 9./255., 9./255., 14./255., 17./255., 19./255., 24./255.};
3362 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3363 }
3364 break;
3365
3366 // South West
3367 case 101:
3368 {
3369 Double_t red[9] = { 82./255., 106./255., 126./255., 141./255., 155./255., 163./255., 142./255., 107./255., 66./255.};
3370 Double_t green[9] = { 62./255., 44./255., 69./255., 107./255., 135./255., 152./255., 149./255., 132./255., 119./255.};
3371 Double_t blue[9] = { 39./255., 25./255., 31./255., 60./255., 73./255., 68./255., 49./255., 72./255., 188./255.};
3372 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3373 }
3374 break;
3375
3376 // Starry Night
3377 case 102:
3378 {
3379 Double_t red[9] = { 18./255., 29./255., 44./255., 72./255., 116./255., 158./255., 184./255., 208./255., 221./255.};
3380 Double_t green[9] = { 27./255., 46./255., 71./255., 105./255., 146./255., 177./255., 189./255., 190./255., 183./255.};
3381 Double_t blue[9] = { 39./255., 55./255., 80./255., 108./255., 130./255., 133./255., 124./255., 100./255., 76./255.};
3382 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3383 }
3384 break;
3385
3386 // Sunset
3387 case 103:
3388 {
3389 Double_t red[9] = { 0./255., 48./255., 119./255., 173./255., 212./255., 224./255., 228./255., 228./255., 245./255.};
3390 Double_t green[9] = { 0./255., 13./255., 30./255., 47./255., 79./255., 127./255., 167./255., 205./255., 245./255.};
3391 Double_t blue[9] = { 0./255., 68./255., 75./255., 43./255., 16./255., 22./255., 55./255., 128./255., 245./255.};
3392 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3393 }
3394 break;
3395
3396 // Temperature Map
3397 case 104:
3398 {
3399 Double_t red[9] = { 34./255., 70./255., 129./255., 187./255., 225./255., 226./255., 216./255., 193./255., 179./255.};
3400 Double_t green[9] = { 48./255., 91./255., 147./255., 194./255., 226./255., 229./255., 196./255., 110./255., 12./255.};
3401 Double_t blue[9] = { 234./255., 212./255., 216./255., 224./255., 206./255., 110./255., 53./255., 40./255., 29./255.};
3402 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3403 }
3404 break;
3405
3406 // Thermometer
3407 case 105:
3408 {
3409 Double_t red[9] = { 30./255., 55./255., 103./255., 147./255., 174./255., 203./255., 188./255., 151./255., 105./255.};
3410 Double_t green[9] = { 0./255., 65./255., 138./255., 182./255., 187./255., 175./255., 121./255., 53./255., 9./255.};
3411 Double_t blue[9] = { 191./255., 202./255., 212./255., 208./255., 171./255., 140./255., 97./255., 57./255., 30./255.};
3412 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3413 }
3414 break;
3415
3416 // Valentine
3417 case 106:
3418 {
3419 Double_t red[9] = { 112./255., 97./255., 113./255., 125./255., 138./255., 159./255., 178./255., 188./255., 225./255.};
3420 Double_t green[9] = { 16./255., 17./255., 24./255., 37./255., 56./255., 81./255., 110./255., 136./255., 189./255.};
3421 Double_t blue[9] = { 38./255., 35./255., 46./255., 59./255., 78./255., 103./255., 130./255., 152./255., 201./255.};
3422 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3423 }
3424 break;
3425
3426 // Visible Spectrum
3427 case 107:
3428 {
3429 Double_t red[9] = { 18./255., 72./255., 5./255., 23./255., 29./255., 201./255., 200./255., 98./255., 29./255.};
3430 Double_t green[9] = { 0./255., 0./255., 43./255., 167./255., 211./255., 117./255., 0./255., 0./255., 0./255.};
3431 Double_t blue[9] = { 51./255., 203./255., 177./255., 26./255., 10./255., 9./255., 8./255., 3./255., 0./255.};
3432 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3433 }
3434 break;
3435
3436 // Water Melon
3437 case 108:
3438 {
3439 Double_t red[9] = { 19./255., 42./255., 64./255., 88./255., 118./255., 147./255., 175./255., 187./255., 205./255.};
3440 Double_t green[9] = { 19./255., 55./255., 89./255., 125./255., 154./255., 169./255., 161./255., 129./255., 70./255.};
3441 Double_t blue[9] = { 19./255., 32./255., 47./255., 70./255., 100./255., 128./255., 145./255., 130./255., 75./255.};
3442 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3443 }
3444 break;
3445
3446 // Cool
3447 case 109:
3448 {
3449 Double_t red[9] = { 33./255., 31./255., 42./255., 68./255., 86./255., 111./255., 141./255., 172./255., 227./255.};
3450 Double_t green[9] = { 255./255., 175./255., 145./255., 106./255., 88./255., 55./255., 15./255., 0./255., 0./255.};
3451 Double_t blue[9] = { 255./255., 205./255., 202./255., 203./255., 208./255., 205./255., 203./255., 206./255., 231./255.};
3452 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3453 }
3454 break;
3455
3456 // Copper
3457 case 110:
3458 {
3459 Double_t red[9] = { 0./255., 25./255., 50./255., 79./255., 110./255., 145./255., 181./255., 201./255., 254./255.};
3460 Double_t green[9] = { 0./255., 16./255., 30./255., 46./255., 63./255., 82./255., 101./255., 124./255., 179./255.};
3461 Double_t blue[9] = { 0./255., 12./255., 21./255., 29./255., 39./255., 49./255., 61./255., 74./255., 103./255.};
3462 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3463 }
3464 break;
3465
3466 // Gist Earth
3467 case 111:
3468 {
3469 Double_t red[9] = { 0./255., 13./255., 30./255., 44./255., 72./255., 120./255., 156./255., 200./255., 247./255.};
3470 Double_t green[9] = { 0./255., 36./255., 84./255., 117./255., 141./255., 153./255., 151./255., 158./255., 247./255.};
3471 Double_t blue[9] = { 0./255., 94./255., 100./255., 82./255., 56./255., 66./255., 76./255., 131./255., 247./255.};
3472 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3473 }
3474 break;
3475
3476 // Viridis
3477 case 112:
3478 {
3479 Double_t red[9] = { 26./255., 51./255., 43./255., 33./255., 28./255., 35./255., 74./255., 144./255., 246./255.};
3480 Double_t green[9] = { 9./255., 24./255., 55./255., 87./255., 118./255., 150./255., 180./255., 200./255., 222./255.};
3481 Double_t blue[9] = { 30./255., 96./255., 112./255., 114./255., 112./255., 101./255., 72./255., 35./255., 0./255.};
3482 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3483 }
3484 break;
3485
3486 // Cividis
3487 case 113:
3488 {
3489 Double_t red[9] = { 0./255., 5./255., 65./255., 97./255., 124./255., 156./255., 189./255., 224./255., 255./255.};
3490 Double_t green[9] = { 32./255., 54./255., 77./255., 100./255., 123./255., 148./255., 175./255., 203./255., 234./255.};
3491 Double_t blue[9] = { 77./255., 110./255., 107./255., 111./255., 120./255., 119./255., 111./255., 94./255., 70./255.};
3492 Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
3493 }
3494 break;
3495
3496 default:
3497 ::Error("SetPalette", "Unknown palette number %d", ncolors);
3498 return;
3499 }
3500 paletteType = ncolors;
3501 if (Idx>0) fgPalettesList.fArray[paletteType-51] = (Double_t)Idx;
3502 else fgPalettesList.fArray[paletteType-51] = 0.;
3503 if (alpha > 0.) fgPalettesList.fArray[paletteType-51] += alpha/10.0f;
3504 return;
3505 }
3506
3507 // set user defined palette
3508 if (colors) {
3509 fgPalette.Set(ncolors);
3510 for (i=0;i<ncolors;i++) fgPalette.fArray[i] = colors[i];
3511 } else {
3512 fgPalette.Set(TMath::Min(50,ncolors));
3513 for (i=0;i<TMath::Min(50,ncolors);i++) fgPalette.fArray[i] = palette[i];
3514 }
3515 paletteType = 3;
3516}
3517
3518
3519////////////////////////////////////////////////////////////////////////////////
3520/// Invert the current color palette.
3521/// The top of the palette becomes the bottom and vice versa.
3522
3524{
3525 std::reverse(fgPalette.fArray, fgPalette.fArray + fgPalette.GetSize());
3526}
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:2804
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:2115
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:2192
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:2426
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:2358
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition TColor.cxx:2320
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:3523
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 GetColorByName(const char *colorname)
Static method returning color index for a color specified by name.
Definition TColor.cxx:1992
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:2015
static Bool_t IsGrayscale()
Return whether all colors return grayscale values.
Definition TColor.cxx:2467
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:2396
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:2047
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:2613
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:2413
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:2507
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:2268
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
static void ListColors(Int_t ci1=0, Int_t ci2=0, Bool_t showEmpty=kFALSE)
List nb colors from the color index ci.
Definition TColor.cxx:2278
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:2079
static void SetGrayscale(Bool_t set=kTRUE)
Set whether all colors should return grayscale values.
Definition TColor.cxx:2475
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
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
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:973
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
static TClass * Class()
Basic string class.
Definition TString.h:139
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:457
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