home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / turbo5 / bgiexamp.arc / DEFPAL.PAS < prev    next >
Pascal/Delphi Source File  |  1988-08-29  |  923b  |  41 lines

  1. { example for GetDefaultPalette }
  2.  
  3. uses
  4.   Crt, Graph;
  5. var
  6.   Driver, Mode,
  7.   i : Integer;
  8.   MyPal, OldPal : PaletteType;
  9.  
  10. begin
  11.   DirectVideo := false;
  12.   Randomize;
  13.   Driver := Detect;                   { Put in graphics mode }
  14.   InitGraph(Driver, Mode, '');
  15.   if GraphResult < 0 then
  16.     Halt(1);
  17.  
  18.   GetDefaultPalette(OldPal);          { preserve old one }
  19.   MyPal := OldPal;                    { duplicate & modify }
  20.  
  21.   { Display something }
  22.   for i := 0 to MyPal.Size - 1 do
  23.   begin
  24.     SetColor(i);
  25.     OutTextXY(10, i * 10, '...Press any key...');
  26.   end;
  27.  
  28.  
  29.   repeat           { Change palette until a key is pressed }
  30.     with MyPal do
  31.       Colors[Random(Size)] := Random(Size + 1);
  32.     SetAllPalette(MyPal);
  33.   until KeyPressed;
  34.  
  35.   SetAllPalette(OldPal);        { restore original palette }
  36.   ClearDevice;
  37.   OutTextXY(10, 10, 'Press <Return>...');
  38.   Readln;
  39.   Closegraph;
  40. end.
  41.