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

  1. {------------------------------------------------------------------------}
  2. { PROJECT   : Turtle graphics using BGI                                  }
  3. { MODULE    : DRAGRECT.PAS                                               }
  4. {------------------------------------------------------------------------}
  5. { GOAL      : Demo program: Draw the Clover leaf dragon                  }
  6. { VERSION   : 1.0                                                        }
  7. {------------------------------------------------------------------------}
  8. { REVISIONS :                                                            }
  9. {------------------------------------------------------------------------}
  10. { AUTHOR    : P.Pollet INSA  16/06/91                                    }
  11. {------------------------------------------------------------------------}
  12.  
  13. program DragonCarre;
  14.  
  15. uses Turtle,Graph,crt;
  16. {..$DEFINE SVGA}      { turn on for SVGA driver }
  17.  
  18. {$IFDEF SVGA}
  19.    {$I SVGA.INI}
  20. {$ENDIF}
  21.  
  22.  
  23. procedure DrR1(N,L:integer);
  24. begin
  25.   If N<1 then
  26.        Forwd(L)
  27.   else
  28.     begin
  29.       DrR1(N-1,L div 3);
  30.       TurnRight(90);
  31.       DrR1(N-1,L div 3);
  32.       TurnLeft(90);
  33.       DrR1(N-1,L div 3);
  34.       TurnLeft(90);
  35.       DrR1(N-1,L div 3);
  36.       TurnRight(90);
  37.       DrR1(N-1,L div 3);
  38.     end
  39. end;
  40.  
  41. procedure DrR2(N,L:integer);
  42. begin
  43.   (*Readln;*)
  44.   If N<1 then
  45.        Forwd(L)
  46.   else
  47.     begin
  48.       DrR2(N-1,L div 3);
  49.       TurnRight(90);
  50.       DrR2(N-1,L div 3);
  51.       TurnLeft(90);
  52.       DrR2(N-1,L div 3);
  53.       TurnLeft(90);
  54.       DrR2(N-1,L div 3);
  55.       DrR2(N-1,L Div 3);
  56.       TurnLeft(90);
  57.       DrR2(N-1,L div 3);
  58.       TurnLeft(90);
  59.       DrR2(N-1,L div 3);
  60.       PenUp;
  61.       TurnLeft(90);
  62.       Forwd (L div 3);
  63.       PenDown;
  64.       DrR2(N-1,L div 3);
  65.     end
  66. end;
  67.  
  68.  
  69. Procedure Dragon(N,L:Integer);
  70. { apply the generator to a square }
  71. begin
  72.   ClearScreen;
  73.   Home;
  74.   PenUp;
  75.   Back(150);
  76.   PenDown;
  77.   DrR1(N,L);
  78.   TurnRight(90);
  79.   DrR1(N,L);
  80.   TurnRight(90);
  81.   DrR1(N,L);
  82.   TurnRight(90);
  83.   DrR1(N,L);
  84. end;
  85.  
  86. var N,L:integer;
  87. begin
  88.    {$IFDEF SVGA}
  89.     Initialize;
  90.     InitTurtle;
  91.   {$ELSE}
  92.     graphon(VGA,VGAHI,'');
  93.   {$ENDIF}
  94.  Wrap;
  95.  Repeat
  96.   OutTextXY(8,8,' N ,L ? ');
  97.   Readln(N); Readln(L);
  98.   ShowTurtle;
  99.   If N >1 Then
  100.     begin
  101.      Dragon(N,L);
  102.      write(^G,^G)
  103.     end;
  104.   HideTurtle;
  105. Until N <1;
  106. graphoff
  107. end.
  108.  
  109.  
  110.