ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
glrose.C
Go to the documentation of this file.
1 // Render a TF2 looking like a rose.
2 // Author: Timur Pocheptsov
3 void glrose()
4 {
5  //Define and set user's palette,
6  //use polar system.
7  const Int_t paletteSize = 10;
8  Float_t rgb[paletteSize * 3] =
9  {0.80f, 0.55f, 0.40f,
10  0.85f, 0.60f, 0.45f,
11  0.90f, 0.65f, 0.50f,
12  0.95f, 0.70f, 0.55f,
13  1.f, 0.75f, 0.60f,
14  1.f, 0.80f, 0.65f,
15  1.f, 0.85f, 0.70f,
16  1.f, 0.90f, 0.75f,
17  1.f, 0.95f, 0.80f,
18  1.f, 1.f, 0.85f};
19 
20  Int_t palette[paletteSize] = {0};
21 
22  for (Int_t i = 0; i < paletteSize; ++i)
23  palette[i] = TColor::GetColor(rgb[i * 3], rgb[i * 3 + 1], rgb[i * 3 + 2]);
24 
25  gStyle->SetPalette(paletteSize, palette);
26 
28  TCanvas *cnv = new TCanvas("glc", "Surface sample", 200, 10, 600, 550);
29 
30  TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98,
31  "\"glsurf2pol\" option + user defined palette.");
32  title->SetFillColor(32);
33  title->Draw();
34 
35  TPad *rosePad = new TPad("box", "box", 0.04, 0.04, 0.96, 0.8);
36  rosePad->Draw();
37 
38 
39  TF2 *fun = new TF2("a", "cos(y)*sin(x)+cos(x)*sin(y)", -6, 6, -6, 6);
40  fun->SetContour(paletteSize);
41  fun->SetNpx(30);
42  fun->SetNpy(30);
43  rosePad->cd();
44  fun->Draw("glsurf2pol");
45 }
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF2.cxx:216
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
Definition: TF1.cxx:3116
float Float_t
Definition: RtypesCore.h:53
void glrose()
Definition: glrose.C:3
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
int Int_t
Definition: RtypesCore.h:41
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1192
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Definition: TStyle.h:337
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:32
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
The most important graphics class in the ROOT system.
Definition: TPad.h:46
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function.
Definition: TF2.cxx:907
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:1023
A 2-Dim function with parameters.
Definition: TF2.h:33
The Canvas class.
Definition: TCanvas.h:48
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
Definition: TPaveLabel.cxx:77
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=0)
Set the number and values of contour levels.
Definition: TF2.cxx:872
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1445