Logo ROOT  
Reference Guide
glrose.C File Reference

Detailed Description

Render a TF2 looking like a rose.

It defines and set a user's palette, and use polar system.

void glrose()
{
const Int_t paletteSize = 10;
Float_t rgb[paletteSize * 3] =
{0.80f, 0.55f, 0.40f,
0.85f, 0.60f, 0.45f,
0.90f, 0.65f, 0.50f,
0.95f, 0.70f, 0.55f,
1.f, 0.75f, 0.60f,
1.f, 0.80f, 0.65f,
1.f, 0.85f, 0.70f,
1.f, 0.90f, 0.75f,
1.f, 0.95f, 0.80f,
1.f, 1.f, 0.85f};
Int_t palette[paletteSize] = {0};
for (Int_t i = 0; i < paletteSize; ++i)
palette[i] = TColor::GetColor(rgb[i * 3], rgb[i * 3 + 1], rgb[i * 3 + 2]);
gStyle->SetPalette(paletteSize, palette);
TCanvas *cnv = new TCanvas("glc", "Surface sample", 200, 10, 600, 550);
TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98,
"\"glsurf2pol\" option + user defined palette.");
title->SetFillColor(32);
title->Draw();
TPad *rosePad = new TPad("box", "box", 0.04, 0.04, 0.96, 0.8);
rosePad->Draw();
TF2 *fun = new TF2("a", "cos(y)*sin(x)+cos(x)*sin(y)", -6, 6, -6, 6);
fun->SetContour(paletteSize);
fun->SetNpx(30);
fun->SetNpy(30);
rosePad->cd();
fun->Draw("glsurf2pol");
}
Author
Timur Pocheptsov

Definition in file glrose.C.

TStyle::SetCanvasPreferGL
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Definition: TStyle.h:325
TPad
Definition: TPad.h:26
TF1::SetNpx
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
Definition: TF1.cxx:3453
TF2::SetNpy
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function.
Definition: TF2.cxx:932
Float_t
float Float_t
Definition: RtypesCore.h:57
Int_t
int Int_t
Definition: RtypesCore.h:45
TF2::SetContour
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=0)
Set the number and values of contour levels.
Definition: TF2.cxx:897
TPaveLabel::Draw
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
Definition: TPaveLabel.cxx:77
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
TF2::Draw
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF2.cxx:241
TColor::GetColor
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition: TColor.cxx:1766
TF2
Definition: TF2.h:29
TPaveLabel
Definition: TPaveLabel.h:20
TStyle::SetPalette
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1785
TCanvas
Definition: TCanvas.h:23
TPad::cd
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:594
TPad::Draw
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1285