29 const Double_t basicColors[][4] =
59 const unsigned nBasicColors =
sizeof basicColors /
sizeof basicColors[0];
62 Color_t CreateRandomGradientFill()
65 if (ROOT::CocoaTutorials::FindFreeCustomColorIndices(idx) != 1)
68 const Double_t *
const fromRGBA = basicColors[(std::rand() % (nBasicColors / 2))];
70 const Double_t *
const toRGBA = basicColors[nBasicColors / 2 + (std::rand() % (nBasicColors / 2))];
72 const Double_t locations[] = {0., 1.};
73 const Double_t rgbas[] = {fromRGBA[0], fromRGBA[1], fromRGBA[2], fromRGBA[3],
74 toRGBA[0], toRGBA[1], toRGBA[2], toRGBA[3]};
76 TRadialGradient *
const grad =
new TRadialGradient(idx[0], 2, locations, rgbas);
77 grad->SetRadialGradient(TColorGradient::Point(0.5, 0.5), 0.5);
83 bool add_ellipse(
const Double_t xC,
const Double_t yC,
const Double_t r)
85 assert(gPad !=
nullptr &&
"add_ellipse, no pad to add ellipse");
87 const Color_t newColor = CreateRandomGradientFill();
89 ::Error(
"add_ellipse",
"failed to find a new color index for a gradient fill");
93 TEllipse *
const newEllipse =
new TEllipse(xC, yC, r, r);
94 newEllipse->SetFillColor(newColor);
103 void radialgradients()
105 gRandom->SetSeed(4357);
107 TCanvas *
const cnv =
new TCanvas(
"radial gradients",
"radial gradients", 800, 800);
108 if (gVirtualX && !gVirtualX->InheritsFrom(
"TGCocoa")) {
109 ::Error(
"radialgradients",
110 "this demo requires OS X and ROOT built with --enable-cocoa");
115 for (
unsigned i = 0; i < 100; ++i)
116 if (!add_ellipse(gRandom->Rndm(), gRandom->Rndm(), 0.5 * gRandom->Rndm()))