Logo ROOT  
Reference Guide
anim.C File Reference

Detailed Description

Macro illustrating how to animate a picture using a Timer.

#include "TStyle.h"
#include "TCanvas.h"
#include "TF2.h"
#include "TTimer.h"
TF2 *f2;
Float_t t = 0;
Float_t phi = 30;
void anim()
{
TCanvas *c1 = new TCanvas("c1");
c1->SetFillColor(17);
f2 = new TF2("f2","sin(2*x)*sin(2*y)*[0]",0,pi,0,pi);
f2->SetParameter(0,1);
f2->SetNpx(15);
f2->SetNpy(15);
f2->SetMaximum(1);
f2->SetMinimum(-1);
f2->Draw("glsurf1");
TTimer *timer = new TTimer(20);
timer->SetCommand("Animate()");
timer->TurnOn();
}
void Animate()
{
//just in case the canvas has been deleted
if (!gROOT->GetListOfCanvases()->FindObject("c1")) return;
t += 0.05*pi;
phi += 2;
gPad->SetPhi(phi);
gPad->Modified();
gPad->Update();
}
Author
Rene Brun

Definition in file anim.C.

TStyle::SetCanvasPreferGL
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Definition: TStyle.h:325
TF1::SetNpx
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
Definition: TF1.cxx:3454
TMath::Cos
Double_t Cos(Double_t)
Definition: TMath.h:630
TF2::SetNpy
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function.
Definition: TF2.cxx:932
TF1::SetMaximum
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum value along Y for this function In case the function is already drawn,...
Definition: TF1.cxx:3415
Float_t
float Float_t
Definition: RtypesCore.h:57
TStyle.h
TTimer.h
TF1::SetMinimum
virtual void SetMinimum(Double_t minimum=-1111)
Set the minimum value along Y for this function In case the function is already drawn,...
Definition: TF1.cxx:3428
TCanvas.h
TF1::SetParameter
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:630
TTimer
Definition: TTimer.h:51
TTimer::SetCommand
void SetCommand(const char *command)
Set the interpreter command to be executed at time out.
Definition: TTimer.cxx:174
TMath::Pi
constexpr Double_t Pi()
Definition: TMath.h:43
TF2.h
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
TF2
Definition: TF2.h:29
Double_t
double Double_t
Definition: RtypesCore.h:59
TCanvas
Definition: TCanvas.h:23
TGeant4Unit::pi
static constexpr double pi
Definition: TGeant4SystemOfUnits.h:73
gPad
#define gPad
Definition: TVirtualPad.h:287
TStyle::SetFrameFillColor
void SetFrameFillColor(Color_t color=1)
Definition: TStyle.h:355
TTimer::TurnOn
virtual void TurnOn()
Add the timer to the system timer list.
Definition: TTimer.cxx:241
gROOT
#define gROOT
Definition: TROOT.h:406
c1
return c1
Definition: legend1.C:41