#include #include #include #include #include "screen.h" #include float XPoint(float,float, float,float, float,float); float YPoint(float,float, float,float, float,float); void fractal(float,float,int,const float); void fname(char [], const int); const float PI=3.1415927; Screen S(600,600); int main(){ ofstream scriptfile("makegif"); ofstream mergegifs("mergegif"); ofstream removal("gifremoval"); char name[10]; S.setrect(-2,-2,4,4); mergegifs << "gifsicle --delay 50 -l "; for (int i=0;i<24;i++){ fname(name,i); fractal(0,0,11,PI*i/48); scriptfile << "convert " << name << ".xpm " << name << ".gif"<< endl; scriptfile << "rm " << name << ".xpm" << endl; mergegifs << name << ".gif "; removal << "rm " << name << ".gif" << endl; S.matrix2xpm(strcat(name,".xpm")); cout << "Done: Image " << i << endl; S.clear(); } mergegifs << "> anim.gif"; return 0; } float XPoint(float xc,float yc, float theta,float scale, float x,float y){ return ((x*cos(theta)-y*sin(theta))*scale+xc); } float YPoint(float xc,float yc, float theta,float scale, float x,float y){ return ((x*sin(theta)+y*cos(theta))*scale+yc); } void fractal(float x, float y, int depth, const float ang){ if (depth==0){ S.plotxy(x,y); } else { fractal(XPoint(1,0,ang,.5,x,y),YPoint(1,0,ang,.5,x,y),depth-1,ang); fractal(XPoint(-1,0,ang,.5,x,y),YPoint(-1,0,ang,.5,x,y),depth-1,ang); fractal(XPoint(0,1,ang,.5,x,y),YPoint(0,1,ang,.5,x,y),depth-1,ang); fractal(XPoint(0,-1,ang,.5,x,y),YPoint(0,-1,ang,.5,x,y),depth-1,ang); } } void fname(char name[], const int n){ strcpy(name,"aa");; name[0]+=(n/26)%26; name[1]+=n%26; }