home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISPEED1.LZH / GRAFDEMO / BOXES2.PAS < prev    next >
Pascal/Delphi Source File  |  1991-07-02  |  1KB  |  60 lines

  1. Program Boxes2;
  2.  
  3. Uses EasyGraf;
  4.  
  5. { Filename: BOXES2.PAS                  }
  6. { Coder   : JVP.                        }
  7. { Coded   : 1-8-1990                    }
  8. { Purpose : Example                     }
  9.  
  10. { The mouse is not shown if you enter .TOS in the OPTIONS/Linker dialog }
  11.  
  12. Const
  13.         XStep    =  2;  { Step value for horizontal lines. }
  14.         YStep    =  3;  { Step value for vertical lines. }
  15.         MaxTimes =  3;  { How many screens will be made? }
  16. Var
  17.         Times    : Byte;        { Screen counter. }
  18.         Direc    : Boolean;     { Direction indicator. }
  19.  
  20.  
  21. { Make boxes, by using resursive calls. }
  22. Procedure Recursive_Boxes( X1,Y1, X2,Y2 : Integer );
  23. Begin
  24.   If (KeyPressed) then
  25.     Exit;
  26.   
  27.   LineColor(Random(MaxColor+1));
  28.   Box(X1,Y1,X2,Y2);
  29.  
  30.   If (Y1 >= MaxY DIV 2) OR (X1 >= MaxX DIV 2) then
  31.     Inc(Times);
  32.  
  33.   If (Times < MaxTimes) then
  34.     Begin
  35.       If (X1 >= MaxX DIV 2) OR (Y1 >= MaxY DIV 2) then
  36.         Direc := FALSE
  37.       ELSE
  38.       If (X1 <= 0) OR (Y1 <= 0) then
  39.         Direc := TRUE;
  40.  
  41.       If (Direc = TRUE) then
  42.         Recursive_Boxes( X1+XStep, Y1+YStep, X2-XStep, Y2-YStep )
  43.       ELSE
  44.         Recursive_Boxes( X1-XStep, Y1-YStep, X2+XStep, Y2+YStep );
  45.     End;
  46. End; { Recursive_Boxes }
  47.  
  48.  
  49. BEGIN { main }
  50.   Randomize;
  51.   InitGraphics;
  52.   ClearDevice;
  53.   Repeat
  54.     Times := 0; 
  55.     Direc := True;
  56.     Recursive_Boxes(0,0,MaxX,MaxY);
  57.   Until KeyPressed;
  58.   DeInitGraphics;
  59. END.
  60.