home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / turbo5 / bgiexamp.arc / WRITMODE.PAS < prev   
Pascal/Delphi Source File  |  1988-08-29  |  1KB  |  39 lines

  1. { example for SetWriteMode }
  2.  
  3. uses
  4.   Crt, Graph;
  5. var
  6.   Driver, Mode,
  7.   i : Integer;
  8.   x1, y1, dx, dy : Integer;
  9.   FillInfo : FillSettingsType;
  10. begin
  11.   DirectVideo := false;                   { turn off screen write }
  12.   Randomize;
  13.   Driver := Detect;                        { Put in graphics mode }
  14.   InitGraph(Driver, Mode, '');
  15.   if GraphResult < 0 then
  16.     Halt(1);
  17.  
  18.   { Fill screen with background pattern }
  19.   GetFillSettings(FillInfo);               { get current settings }
  20.   SetFillStyle(WideDotFill, FillInfo.Color);
  21.   Bar(0, 0, GetMaxX, GetMaxY);
  22.  
  23.   dx := GetMaxX div 4;         { determine rectangle's dimensions }
  24.   dy := GetMaxY div 4;
  25.  
  26.   SetLineStyle(SolidLn, 0, ThickWidth);
  27.   SetWriteMode(XORput);                  { XOR mode for rectangle }
  28.   repeat                            { draw until a key is pressed }
  29.     x1 := Random(GetMaxX - dx);
  30.     y1 := Random(GetMaxY - dy);
  31.     Rectangle(x1, y1, x1 + dx, y1 + dy);                { draw it }
  32.     Delay(10);                                    { pause briefly }
  33.     Rectangle(x1, y1, x1 + dx, y1 + dy);               { erase it }
  34.   until KeyPressed;
  35.  
  36.   Readln;
  37.   Closegraph;
  38. end.
  39.