Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
glrose.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_gl
3/// Render a TF2 looking like a rose.
4///
5/// It defines and set a user's palette, and use polar system.
6///
7/// \macro_image(nobatch)
8/// \macro_code
9///
10/// \author Timur Pocheptsov
11
12void glrose()
13{
14 const Int_t paletteSize = 10;
15 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,
16 0.70f, 0.55f, 1.f, 0.75f, 0.60f, 1.f, 0.80f, 0.65f, 1.f, 0.85f,
17 0.70f, 1.f, 0.90f, 0.75f, 1.f, 0.95f, 0.80f, 1.f, 1.f, 0.85f};
18
19 Int_t palette[paletteSize] = {0};
20
21 for (Int_t i = 0; i < paletteSize; ++i)
22 palette[i] = TColor::GetColor(rgb[i * 3], rgb[i * 3 + 1], rgb[i * 3 + 2]);
23
24 gStyle->SetPalette(paletteSize, palette);
25
26 gStyle->SetCanvasPreferGL(1);
27 TCanvas *cnv = new TCanvas("glc", "Surface sample", 200, 10, 600, 550);
28
30 title->SetFillColor(32);
31 title->Draw();
32
33 TPad *rosePad = new TPad("box", "box", 0.04, 0.04, 0.96, 0.8);
34 rosePad->Draw();
35
36 TF2 *fun = new TF2("a", "cos(y)*sin(x)+cos(x)*sin(y)", -6, 6, -6, 6);
37 fun->SetContour(paletteSize);
38 fun->SetNpx(30);
39 fun->SetNpy(30);
40 rosePad->cd();
41 fun->Draw("glsurf2pol");
42}
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
externTStyle * gStyle
Definition TStyle.h:442
The Canvas class.
Definition TCanvas.h:23
static Int_t GetColor(const char *hexcolor)
virtual void SetNpx(Int_t npx=100)
Definition TF2.h:29
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=nullptr)
void Draw(Option_t *option="") override
Default Draw method for all objects.
virtual void SetNpy(Int_t npy=100)
The most important graphics class in the ROOT system.
Definition TPad.h:28
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition TPad.cxx:694
void Draw(Option_t *option="") override
Draw Pad in Current pad (re-parent pad if necessary).
Definition TPad.cxx:1512
A Pave (see TPave) with a text centered in the Pave.
Definition TPaveLabel.h:20