This tutorial demonstrates how to use radial gradients, custom colors, transparency.
Requires OpenGL or Web-based canvas
{
for (
int n = 0;
n < 2; ++
n)
if (gradient) {
gradient->SetRadialGradient({0.3, 0.3}, 0.7);
gradient->SetColorAlpha(0, 0.2 +
gRandom->Rndm() * 0.8);
gradient->SetColorAlpha(1, 0.2 +
gRandom->Rndm() * 0.8);
} else {
::Error(
"CreateRandomGradientFill",
"failed to find new gradient color with index %d", indx);
}
return indx;
}
{
const Color_t newColor = CreateRandomGradientFill();
if (newColor == -1) {
::Error(
"add_ellipse",
"failed to find a new color index for a gradient fill");
return false;
}
return true;
}
void radialgradients(bool gl = true)
{
gStyle->SetCanvasPreferGL(gl);
auto cnv =
new TCanvas(
"radialgradients",
"radial gradients", 800, 800);
if (!cnv->UseGL() && !cnv->IsWeb())
"This macro requires either OpenGL or Web canvas to correctly handle gradient colors");
for (unsigned i = 0; i < 100; ++i)
}
double Double_t
Double 8 bytes.
short Color_t
Color number (short).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
static Int_t GetRadialGradient(Double_t r, const std::vector< Int_t > &colors, const std::vector< Double_t > &positions={})
void Draw(Option_t *option="") override
Default Draw method for all objects.
- Authors
- Timur Pocheptsov, Sergey Linev
Definition in file radialgradients.C.