/////////////////////////////////////////////////////////////////// // // graphics1.cpp // // Started in Pascal by Jeff Ondich on 1/25/95 // Last modified 5/19/98 // // // 1. Compile it, run it, and read all the procedures to // see what they do. // // 2. Try changing the parameters passed to SayHello(). What // do rmoveto() and rlineto() do? Which is a more generally // useful function--SayHello(), or SayHelloAgain()? Why? // /////////////////////////////////////////////////////////////////// #include #include // Constants const int windowWidth = 600; const int windowHeight = 600; const int windowBottom = 100; const int windowLeft = 100; // Prototypes void StartGraphics( void ); void SayHello( int startX, int startY ); void SayHelloAgain( void ); void DrawSomeCircles( void ); int main( void ) { StartGraphics(); SayHello( 100, 490 ); SayHelloAgain(); DrawSomeCircles(); cin.ignore(); return( 0 ); } void SayHello( int startX, int startY ) { setrgbcolor( 1.0, 1.0, 1.0 ); moveto( startX, startY ); rlineto( 30, 80 ); rlineto( -10, 20 ); rlineto( 0, -100 ); rlineto( 10, 30 ); rlineto( 10, 0 ); rlineto( 10, -30 ); rlineto( 15, 0 ); rlineto( 10, 30 ); rlineto( 5, -20 ); rmoveto( -10, 40 ); rlineto( 0, 2 ); flushgraphics(); } void SayHelloAgain( void ) { char greeting[20] = "Howdy"; setrgbcolor( 1, 0, 0 ); setfont( 1, 36 ); showtextXY( 350, 400, greeting ); setrgbcolor( 0, 1, 0 ); moveto( 380, 350 ); showtext( greeting ); flushgraphics(); } void DrawSomeCircles( void ) { setrgbcolor( 0, 0, 1 ); circle( 150, 250, 50 ); circlefilled( 350, 250, 50 ); flushgraphics(); } /////////////////////////////////////////////////////////////////// // StartGraphics initializes the graphics package // and opens a black window for drawing. /////////////////////////////////////////////////////////////////// void StartGraphics( void ) { // Call initializegraphics only once during the program, // before you do any other graphics initializegraphics(); // Open a window and flood it with a black background. createwindow( windowLeft, windowBottom, windowLeft + windowWidth, windowBottom + windowHeight ); setrgbcolor( 0.0, 0.0, 0.0 ); flood(); flushgraphics(); }