home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST1009.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-07-31  |  2.0 KB  |  47 lines

  1. Program BlackImageDemo;
  2. {--------------------------------------------------------------}
  3. { This program will draw a black image on a colored background }
  4. { by manipulating the EGA's palette.  This routine will also   }
  5. { unmodified on a VGA card.                                    }
  6. {--------------------------------------------------------------}
  7.  
  8. Uses Crt, Graph;       { Link in necessary support routines    }
  9.  
  10. Const
  11.   PathForDrivers = ''; { Location of BGI support files         }
  12.  
  13. Var
  14.   GraphDriver,         { Variables for InitGraph procedure     }
  15.   GraphMode : Integer;
  16.   MaxX,
  17.   MaxY : Word;         { Values to store maximum resolution    }
  18.   Ch : Char;           { Character used to pause output screen }
  19.   ColorNumber : Word;  { Input value that is the target color  }
  20.  
  21. Begin
  22.   ClrScr;
  23.   Repeat                 { Loop until valid input is received  }
  24.     GotoXY( 5,2 );
  25.     Write( 'Enter color number for background: ' );
  26.     Readln( ColorNumber );
  27.   Until( ColorNumber > 0 ) and ( ColorNumber < 16 );
  28.   GraphDriver := Detect;{ Request Autodetection for graphics   }
  29.   InitGraph( GraphDriver, GraphMode, PathForDrivers );
  30.                         { Place system into graphics mode      }
  31.   MaxX := GetMaxX;      { Store maximum X resolution           }
  32.   MaxY := GetMaxY;      { Store maximum Y resolution           }
  33.   SetBKColor( ColorNumber );
  34.                         { Reset BK Color to selected color     }
  35.   SetPalette( ColorNumber,0 );
  36.                         { Place Black into selected color loc. }
  37.   SetColor( ColorNumber );
  38.                         { Choose "new" black as drawing color  }
  39.                         { Now draw several images on screen    }
  40.   Rectangle( 5,5,MaxX - 5,MaxY - 5 );
  41.   Circle( MaxX Div 2, MaxY Div 2, 75 );
  42.   Line( MaxX Div 2,0,MaxX Div 2, MaxY );
  43.   Line( 0,MaxY Div 2, MaxX, MaxY Div 2 );
  44.   Ch := Readkey;        { Pause for screen viewing             }
  45.   CloseGraph;           { Shut down graphics system            }
  46. End.
  47.