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

  1. {M 10,10,20,20}
  2.  
  3. Program Boxes1;
  4.  
  5. Uses EasyGraf;
  6.  
  7. { Filename: Boxes1.pas        }
  8. { Coder   : Jacob V. Pedersen }
  9. { Coded   : 1-8-1990          }
  10. { Purpose : Example           }
  11.  
  12. { The mouse is not shown if you enter .TOS in the OPTIONS/Linker dialog }
  13.  
  14. Const
  15.         StepX   = 1;
  16.         StepY   = 1;
  17. Var
  18.         ShiftX  : Byte;
  19.         ShiftY  : Byte;
  20.         Boxes   : Integer;
  21.  
  22.  
  23. { Makes a number of boxes, all filled with smaller boxes. }
  24. Procedure MakeBoxes;
  25. Var
  26.         Xlng,
  27.         Ylng,
  28.         X,Y     : Integer;
  29.  
  30. Procedure FillBox( X1,Y1, X2,y2 : Integer);
  31. Begin
  32.   If KeyPressed then
  33.     Exit;
  34.   LineColor(Random(MaxColor+1));
  35.   Box(x1,y1,x2,y2);
  36.   
  37.   If (X1+stepx < X2) AND (Y1+stepy < Y2) then
  38.     Fillbox( x1+stepx, y1+stepy, x2-stepx, y2-stepy );
  39. End; { FillBox }
  40.  
  41.  
  42. Begin
  43.   Xlng   := (MaxX DIV Boxes)-1;
  44.   Ylng   := (MaxY DIV Boxes)-1;
  45.   ShiftX := (MaxX MOD Boxes) DIV 2;
  46.   ShiftY := (MaxY MOD Boxes) DIV 2;
  47.  
  48.   For X := 0 to Boxes-1 DO
  49.     For Y := 0 to Boxes-1 do
  50.       Begin
  51.         FillBox(ShiftX+(X*Xlng)+X,
  52.                 ShiftY+(Y*Ylng)+Y,
  53.                 ShiftX+(Xlng*succ(X))+X,
  54.                 ShiftY+(Ylng*succ(Y))+Y);
  55.       End;
  56. End; { MakeBoxes }
  57.  
  58.  
  59. BEGIN { main }
  60.   Randomize;
  61.   InitGraphics;
  62.   ClearDevice;
  63.   Boxes := 0;
  64.   Repeat
  65.    Inc(Boxes); 
  66.    MakeBoxes; 
  67.   Until (KeyPressed) OR (Boxes = 400);
  68.   DeInitGraphics;
  69. END.
  70.