Skip to content
Snippets Groups Projects
Commit 4ac4abb1 authored by Timur Pocheptsov's avatar Timur Pocheptsov
Browse files

Update a grad2.C tutorial to use TLinearGradient.

parent cf3791ac
Branches
Tags
No related merge requests found
......@@ -369,13 +369,10 @@ void CalculateGradientPoints(const TColorGradient *extendedColor, const CGSize &
//TODO: that's stupid, but ... radial can iherit linear to make things easier :)
if (const TLinearGradient * const lGrad = dynamic_cast<const TLinearGradient *>(extendedColor)) {
start = CGPointMake(lGrad->GetStartPoint().fX, lGrad->GetStartPoint().fY);
end.x = lGrad->GetEndPoint().fX;
end.y = lGrad->GetEndPoint().fY;
end = CGPointMake(lGrad->GetEndPoint().fX, lGrad->GetEndPoint().fY);
} else if (const TRadialGradient * const rGrad = dynamic_cast<const TRadialGradient *>(extendedColor)) {
start.x = rGrad->GetStartPoint().fX;
start.y = rGrad->GetStartPoint().fY;
end.x = rGrad->GetEndPoint().fX;
end.y = rGrad->GetEndPoint().fY;
start = CGPointMake(rGrad->GetStartPoint().fX, rGrad->GetStartPoint().fY);
end = CGPointMake(rGrad->GetEndPoint().fX, rGrad->GetEndPoint().fY);
}
if (mode == TColorGradient::kObjectBoundingMode) {
......
......@@ -43,15 +43,22 @@ void grad2()
// b) Gradient (from our semi-transparent red to ROOT's kOrange).
const Double_t locations[] = {0., 1.};
const Color_t idx1[] = {kOrange, customRed};
new TColorGradient(grad1, TColorGradient::kGDVertical, 2, locations, idx1);
const Color_t idx1[] = {customRed, kOrange};
TLinearGradient * const gradFill1 = new TLinearGradient(grad1, 2, locations, idx1);
typedef TColorGradient::GradientPoint point_type;
//Starting and ending points for a gradient fill (it's a vertical gradient):
gradFill1->SetStartEnd(point_type(0., 0.), point_type(0., 1));
// c) Custom semi-transparent green.
new TColor(customGreen, 0., 1., 0., "green", 0.5);
// d) Gradient from ROOT's kBlue to our custom green.
const Color_t idx2[] = {kBlue, customGreen};
new TColorGradient(grad2, TColorGradient::kGDVertical, 2, locations, idx2);
const Color_t idx2[] = {customGreen, kBlue};
TLinearGradient * const gradFill2 = new TLinearGradient(grad2, 2, locations, idx2);
//Vertical gradient fill.
gradFill2->SetStartEnd(point_type(0., 0), point_type(0., 1.));
TH1F * hist = new TH1F("a2", "b2", 10, -2., 3.);
TH1F * hist2 = new TH1F("c3", "d3", 10, -3., 3.);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment