30 Color_t freeIndices[4] = {};
31 if (ROOT::GLTutorials::FindFreeCustomColorIndices(freeIndices) != 4) {
32 ::Error(
"grad2",
"can not allocate new custom colors");
37 const Color_t customRed = freeIndices[0], grad1 = freeIndices[1];
38 const Color_t customGreen = freeIndices[2], grad2 = freeIndices[3];
41 gStyle->SetCanvasPreferGL(kTRUE);
44 TCanvas *
const cnv =
new TCanvas(
"gradiend demo 2",
"gradient demo 2", 100, 100, 800, 600);
46 ::Error(
"grad2",
"This macro requires OpenGL");
53 new TColor(customRed, 1., 0., 0.,
"red", 0.5);
66 const Double_t locations[] = {0., 1.};
67 const Color_t idx1[] = {customRed, kOrange};
68 TLinearGradient *
const gradFill1 =
new TLinearGradient(grad1, 2, locations, idx1);
70 typedef TColorGradient::Point Point;
72 gradFill1->SetStartEnd(Point(0., 0.), Point(0., 1.));
75 new TColor(customGreen, 0., 1., 0.,
"green", 0.5);
78 const Color_t idx2[] = {customGreen, kBlue};
80 TLinearGradient *
const gradFill2 =
new TLinearGradient(grad2, 2, locations, idx2);
82 gradFill2->SetStartEnd(Point(0., 0.), Point(0., 1.));
84 TH1F *
const hist =
new TH1F(
"a2",
"b2", 10, -2., 3.);
85 TH1F *
const hist2 =
new TH1F(
"c3",
"d3", 10, -3., 3.);
86 hist->FillRandom(
"landau", 100000);
87 hist2->FillRandom(
"gaus", 100000);
89 hist->SetFillColor(grad1);
90 hist2->SetFillColor(grad2);