33 TH2F *last_histo=NULL;
35 void mygenerate(
double factor,
double cen_x,
double cen_y)
37 printf(
"Regenerating...\n");
41 double dx=last_histo->GetXaxis()->GetXmax()-last_histo->GetXaxis()->GetXmin();
42 double dy=last_histo->GetYaxis()->GetXmax()-last_histo->GetYaxis()->GetXmin();
44 last_histo->GetNbinsX(),
47 last_histo->GetNbinsY(),
55 if(last_histo!=NULL)
delete last_histo;
57 last_histo=
new TH2F(
"h2",
58 "Mandelbrot [move mouse and press z to zoom, u to unzoom, r to reset]",
60 last_histo->SetStats(0);
62 const int max_iter=50;
63 for(
int bx=1;bx<=last_histo->GetNbinsX();bx++)
64 for(
int by=1;by<=last_histo->GetNbinsY();by++)
66 double x=last_histo->GetXaxis()->GetBinCenter(bx);
67 double y=last_histo->GetYaxis()->GetBinCenter(by);
73 last_histo->Fill(x,y);
75 if(iter>max_iter)
break;
78 last_histo->SetContour(99);
79 last_histo->Draw(
"colz");
88 int event = gPad->GetEvent();
89 int px = gPad->GetEventX();
90 int py = gPad->GetEventY();
93 double xd = gPad->AbsPixeltoX(px);
94 double yd = gPad->AbsPixeltoY(py);
95 float x = gPad->PadtoX(xd);
96 float y = gPad->PadtoY(yd);
111 mygenerate(1./Z, last_x, last_y);
114 mygenerate(Z , last_x, last_y);
117 mygenerate(-1 , last_x, last_y);
125 gStyle->SetPadGridX(kTRUE);
126 gStyle->SetPadGridY(kTRUE);
127 new TCanvas(
"canvas",
"View Mandelbrot set");
132 gPad->AddExec(
"myexec",
"myexec()");