/////////////////////////////////////////////////////////////////// // // graphics1.cpp // // Started in Pascal by Jeff Ondich on 1/25/95 // Last modified 1/17/00 // // // 1. Compile it, run it, and read all the functions to // see what they do. // // 2. Try changing the parameters passed to SayHello(). What // do g2_move_r() and g2_line_r() do? Which is a more generally // useful function--SayHello(), or SayHelloAgain()? Why? // /////////////////////////////////////////////////////////////////// #include #include #include // Prototypes void SayHello( int window, int startX, int startY ); void SayHelloAgain( int window ); void DrawSomeCircles( int window ); // Defined constants const int windowWidth = 500; const int windowHeight = 500; int main() { ///////////////////////////////////// // Open the graphics window. ///////////////////////////////////// int window = g2_open_X11( windowWidth, windowHeight ); ///////////////////////////////////// // Clear the window. ///////////////////////////////////// g2_set_background( window, g2_ink(window,0,0,0) ); ///////////////////////////////////// // Draw. ///////////////////////////////////// SayHello( window, 100, 400 ); SayHelloAgain( window ); DrawSomeCircles( window ); ///////////////////////////////////// // Clean up. ///////////////////////////////////// cout << "Click in this window and hit return to quit." << endl; cin.get(); g2_close( window ); return( 0 ); } void SayHello( int window, int startX, int startY ) { g2_pen( window, g2_ink(window,1,1,1) ); g2_move( window, startX, startY ); g2_line_r( window, 30, 80 ); g2_line_r( window, -10, 20 ); g2_line_r( window, 0, -100 ); g2_line_r( window, 10, 30 ); g2_line_r( window, 10, 0 ); g2_line_r( window, 10, -30 ); g2_line_r( window, 15, 0 ); g2_line_r( window, 10, 30 ); g2_line_r( window, 5, -20 ); g2_move_r( window, -10, 40 ); g2_line_r( window, 0, 2 ); } void SayHelloAgain( int window ) { char greeting[20] = "Howdy"; g2_pen( window, g2_ink(window,1,0,0) ); g2_set_font_size( window, 24 ); g2_string( window, 350, 400, greeting ); } void DrawSomeCircles( int window ) { g2_pen( window, g2_ink(window,0,0,1) ); g2_circle( window, 150, 250, 50 ); g2_filled_circle( window, 350, 250, 50 ); }