home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / Pascal / TURTLE10.ZIP / TREEREC.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-12-14  |  1.5 KB  |  53 lines

  1. {------------------------------------------------------------------------}
  2. { PROJECT   : Turtle graphics using BGI                                  }
  3. { MODULE    :  TREEREC.PAS                                               }
  4. {------------------------------------------------------------------------}
  5. { GOAL      : Demo program for drawing recursive simple trees            }
  6. { VERSION   : 1.0                                                        }
  7. {------------------------------------------------------------------------}
  8. { REVISIONS :                                                            }
  9. {------------------------------------------------------------------------}
  10. { AUTHOR    : P.Pollet INSA  14/06/91                                    }
  11. {------------------------------------------------------------------------}
  12.  
  13. program TreeRec;
  14.  
  15. uses graph,Turtle;
  16.  
  17. var Color:integer;
  18.  
  19. procedure Tree (Ainit,A,alpha,K,N:integer);
  20. begin
  21.   (*readln;*)
  22.   Color:=Color+1;
  23.   If Color=4 then Color:=1;
  24.   setpencolor(Color);
  25.   If (A>0) and (N>0) then
  26.     begin
  27.       K:=Random(Ainit div 5)+1;
  28.       Forwd(A);
  29.       TurnLeft(Alpha);
  30.       Tree(Ainit,A-K,alpha,K,N-1);
  31.       TurnRight(2*Alpha);
  32.       K:=Random(Ainit div 5 )+1;
  33.       Tree(Ainit,A-K,alpha,K,N-1);
  34.       TurnLeft(Alpha);
  35.       ForWd(-A);
  36.     end
  37.  end;
  38.  var i:integer;
  39.  
  40.  
  41. begin
  42.   graphon(VGA,VGAHI,'c:\tp\bgi');
  43.   PenUp;
  44.   Home;
  45.   Forwd(-100);
  46.   PenDown;
  47.   Color:=0;
  48.   ShowTurtle;
  49.       Tree(25,55,20,18,6) ;
  50.   readln;
  51.   GraphOff
  52. end.
  53.