27 Color_t freeIndices[4] = {};
28 if (ROOT::CocoaTutorials::FindFreeCustomColorIndices(freeIndices) != 4) {
29 ::Error(
"grad2",
"can not allocate new custom colors");
34 const Color_t customRed = freeIndices[0], grad1 = freeIndices[1];
35 const Color_t customGreen = freeIndices[2], grad2 = freeIndices[3];
38 TCanvas *
const cnv =
new TCanvas(
"gradient demo 2",
"gradient demo 2", 100, 100, 800, 600);
40 if (gVirtualX && !gVirtualX->InheritsFrom(
"TGCocoa")) {
41 ::Error(
"grad2",
"This macro works only on OS X with --enable-cocoa");
48 new TColor(customRed, 1., 0., 0.,
"red", 0.5);
59 const Double_t locations[] = {0., 1.};
60 const Color_t idx1[] = {customRed, kOrange};
61 TLinearGradient *
const gradFill1 =
new TLinearGradient(grad1, 2, locations, idx1);
63 typedef TColorGradient::Point Point;
65 gradFill1->SetStartEnd(Point(0., 0.), Point(0., 1.));
68 new TColor(customGreen, 0., 1., 0.,
"green", 0.5);
71 const Color_t idx2[] = {customGreen, kBlue};
73 TLinearGradient *
const gradFill2 =
new TLinearGradient(grad2, 2, locations, idx2);
75 gradFill2->SetStartEnd(Point(0., 0), Point(0., 1.));
77 TH1F *
const hist =
new TH1F(
"a2",
"b2", 10, -2., 3.);
78 TH1F *
const hist2 =
new TH1F(
"c3",
"d3", 10, -3., 3.);
79 hist->FillRandom(
"landau", 100000);
80 hist2->FillRandom(
"gaus", 100000);
82 hist->SetFillColor(grad1);
83 hist2->SetFillColor(grad2);