#include "glib.h"
int N=14; /*递归次数*/
double sx=220.0,sy=280.0; /*开始点坐标*/
double leng0=200.0; /*开始点与结束点的距离*/
double a,b,t=0.5;
void fractal(double x0,double y0,double x1,double y1) /*分形图形描画函数*/
{
double px,py;
if ((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)>=2.0)
{
px=x0+(a*(x1-x0)-b*(y1-y0));
py=y0+(b*(x1-x0)+a*(y1-y0));
putpixel(px,-py,15);
fractal(x0,y0,px,py);
fractal(px,py,x1,y1);
}
}
void main()
{
ginit();
set0(sx,sy);
a=1/(1+t*t);
b=t/(1+t*t);
putpixel(0,0,9); /*描画开始点*/
putpixel(leng0,0,12); /*描画结束点*/
fractal(0.0,0.0,leng0,0.0);
gend();
}