home *** CD-ROM | disk | FTP | other *** search
- Program BlackImageDemo;
- {--------------------------------------------------------------}
- { This program will draw a black image on a colored background }
- { by manipulating the EGA's palette. This routine will also }
- { unmodified on a VGA card. }
- {--------------------------------------------------------------}
-
- Uses Crt, Graph; { Link in necessary support routines }
-
- Const
- PathForDrivers = ''; { Location of BGI support files }
-
- Var
- GraphDriver, { Variables for InitGraph procedure }
- GraphMode : Integer;
- MaxX,
- MaxY : Word; { Values to store maximum resolution }
- Ch : Char; { Character used to pause output screen }
- ColorNumber : Word; { Input value that is the target color }
-
- Begin
- ClrScr;
- Repeat { Loop until valid input is received }
- GotoXY( 5,2 );
- Write( 'Enter color number for background: ' );
- Readln( ColorNumber );
- Until( ColorNumber > 0 ) and ( ColorNumber < 16 );
- GraphDriver := Detect;{ Request Autodetection for graphics }
- InitGraph( GraphDriver, GraphMode, PathForDrivers );
- { Place system into graphics mode }
- MaxX := GetMaxX; { Store maximum X resolution }
- MaxY := GetMaxY; { Store maximum Y resolution }
- SetBKColor( ColorNumber );
- { Reset BK Color to selected color }
- SetPalette( ColorNumber,0 );
- { Place Black into selected color loc. }
- SetColor( ColorNumber );
- { Choose "new" black as drawing color }
- { Now draw several images on screen }
- Rectangle( 5,5,MaxX - 5,MaxY - 5 );
- Circle( MaxX Div 2, MaxY Div 2, 75 );
- Line( MaxX Div 2,0,MaxX Div 2, MaxY );
- Line( 0,MaxY Div 2, MaxX, MaxY Div 2 );
- Ch := Readkey; { Pause for screen viewing }
- CloseGraph; { Shut down graphics system }
- End.