This macro requires OS X and ROOT compiled with –enable-cocoa to run.
Features:
- Radial and linear gradients
- Transparent/semitransparent colours.
- Shadows.
void gradients(bool gl = true)
{
gStyle->SetCanvasPreferGL(gl);
auto c =
new TCanvas(
"cpie",
"Gradient colours demo", 700, 700);
if (!
c->UseGL() && !
c->IsWeb())
::Warning(
"gradients",
"This macro requires either OpenGL or Web canvas to correctly handle gradient colors");
auto t =
new TText(0.05, 0.7,
"Can you see the text?");
t->Draw();
auto pad =
new TPad(
"p",
"p", 0., 0., 1., 1.);
pad->SetFillColor(transparentFill);
pad->Draw();
pad->cd();
c->SetFillColor(linearFill);
Double_t values[nSlices] = {0.8, 1.2, 1.2, 0.8, 1.};
Int_t colors[nSlices] = {radialFill, radialFill, radialFill, radialFill, radialFill};
}
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
static Int_t GetRadialGradient(Double_t r, const std::vector< Int_t > &colors, const std::vector< Double_t > &positions={})
static Int_t GetLinearGradient(Double_t angle, const std::vector< Int_t > &colors, const std::vector< Double_t > &positions={})
static Int_t GetColor(const char *hexcolor)
The most important graphics class in the ROOT system.
void SetLabelsOffset(Float_t)
void SetEntryRadiusOffset(Int_t, Double_t)
void Draw(Option_t *option="l") override
Default Draw method for all objects.
- Author
- Timur Pocheptsov
Definition in file gradients.C.