32 Color_t colorIndices[5] = {};
33 if (ROOT::GLTutorials::FindFreeCustomColorIndices(colorIndices) != 5) {
34 ::Error(
"grad",
"failed to create new custom colors");
39 gStyle->SetCanvasPreferGL(kTRUE);
42 TCanvas *
const cnv =
new TCanvas(
"gradient demo 1",
"gradient demo 1", 100, 100, 600, 600);
44 ::Error(
"grad",
"This macro requires OpenGL");
49 typedef TColorGradient::Point Point;
60 const Color_t &frameGradient = colorIndices[2];
63 new TColor(colorIndices[0], 0.25, 0.25, 0.25,
"special pad color1", 0.55);
64 new TColor(colorIndices[1], 1., 1., 1.,
"special pad color2", 0.05);
67 const Double_t locations[] = {0., 0.2, 0.8, 1.};
68 const Color_t gradientIndices[4] = {colorIndices[0], colorIndices[1], colorIndices[1], colorIndices[0]};
71 TLinearGradient *
const gradFill1 =
new TLinearGradient(frameGradient, 4, locations, gradientIndices);
73 gradFill1->SetStartEnd(Point(0., 0.), Point(1., 0.));
77 const Color_t &padGradient = colorIndices[3];
80 const Double_t locations[] = {0., 1.};
81 const Color_t gradientIndices[4] = {30, 38};
84 TLinearGradient *
const gradFill2 =
new TLinearGradient(padGradient, 2, locations, gradientIndices);
86 gradFill2->SetStartEnd(Point(0., 0.), Point(0., 1.));
90 const Color_t &histGradient = colorIndices[4];
93 const Color_t gradientIndices[3] = {kYellow, kOrange, kRed};
94 const Double_t locations[3] = {0., 0.5, 1.};
97 TLinearGradient *
const gradFill3 =
new TLinearGradient(histGradient, 3, locations, gradientIndices);
99 gradFill3->SetStartEnd(Point(0., 0.), Point(0., 1.));
102 cnv->SetFillColor(padGradient);
103 cnv->SetFrameFillColor(frameGradient);
105 TH1F *
const hist =
new TH1F(
"a1",
"b1", 20, -3., 3.);
106 hist->SetFillColor(histGradient);
107 hist->FillRandom(
"gaus", 100000);