manthanthakker40

CG_FRACTAL TREE

Nov 3rd, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<graphics.h>
  4. #define angle (30*3.145)/180
  5. #include<math.h>
  6. r(int l,double a,int x,int y)
  7. {
  8.     if(l!=0)
  9.     {
  10.         double a1=a+angle;
  11.         double a2=a-angle;
  12.         int x1=x+l*cos(a1);
  13.         int y1=y-l*sin(a1);
  14.         line(x,y,x1,y1);
  15.         r(l/2,a1,x1,y1);
  16.         x1=x+l*cos(a2);
  17.         y1=y-l*sin(a2);
  18.         line(x,y,x1,y1);
  19.         r(l/2,a2,x1,y1);
  20.  
  21.     }
  22. }
  23. void fractal()
  24. {
  25.     printf("fractal tree");
  26.     line(400,600,400,400);
  27.     r(150,(90*3.14)/180,400,400);
  28.     getch();
  29. }
  30.  
  31.  
  32. void main()
  33. {
  34.     int gd=DETECT,gm;
  35.     initgraph(&gd,&gm,"c:\\tc1\\tc\\tc\\bgi");
  36.     fractal();
  37.  
  38.     getch();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment