/////////////////////////////////////////////// // // face.cpp // Mike Tie, Fall 1999 // Modified by Jeff Ondich, 11/5/99 // // This program illustrates the g2 graphics // library by opening a window and drawing // a face. // // Compile it with: // // g++ -o face face.cpp -L/usr/X11R6/lib -lm -lX11 -lgd -lg2 // // To get the hang of programming with // graphics, try changing colors on the // face, or drawing a different mouth, // or adding hair. // /////////////////////////////////////////////// #include #include #include const int HEIGHT= 200; const int WIDTH = 200; int main(void) { // Open a window on screen. Keep its device ID // in an int variable. int window = g2_open_X11(WIDTH, HEIGHT); // Define some colors. int black_ink = g2_ink( window, 0, 0, 0 ); int blue_ink = g2_ink( window, 0, 0, 1 ); int yellow_ink = g2_ink( window, 0.7, 0.7, 0 ); int white_ink = g2_ink( window, 1, 1, 1 ); // Clear the window, giving it a black background. g2_set_background( window, black_ink ); // Draw the face,... g2_pen( window, yellow_ink ); g2_filled_circle( window, 100, 100, 50 ); // ...and eyes,... g2_pen( window, white_ink ); g2_filled_ellipse( window, 85, 115, 9, 6 ); g2_filled_ellipse( window, 115, 115, 9, 6 ); g2_pen( window, blue_ink ); g2_filled_circle( window, 83, 115, 5 ); g2_filled_circle( window, 113, 115, 5 ); g2_pen( window, black_ink ); g2_filled_circle( window, 83, 115, 3 ); g2_filled_circle( window, 113, 115, 3 ); // ...and a nose,... g2_pen( window, black_ink ); g2_line( window, 102, 105, 95, 88 ); g2_line( window, 95, 88, 102, 88 ); // ...and a mouth,... g2_line( window, 90, 80, 110, 80 ); // ...and a name. g2_set_font_size( window, 14 ); g2_pen( window, white_ink ); g2_string( window, 10, 25, "Hi, I'm Mike!" ); // Wait for user input before closing // the window and finishing the program. cout << "Hit return when you're done with the face." << endl; cin.get(); g2_close(window); return( 0 ); }