// File: snowmen.cxx // Written by Michael Main (main@colorado.edu) // This program opens a large, square graphics window and // draws six snowmen of various sizes and locations. // Directives: #include #include #include using namespace std; // Named constants: const int S = 500; // Width and height of the graphics window. // Prototypes: // This function draws a snowman with the center of the body // at (x,y), the radius of the body given by the 3rd // paramter. The head is always right on top of the body // with a radius that is half that of the body. void draw_snowman(int x, int y, int radius); // Function definitions: //---------------------------------------------------------- int main( ) { // 1. Initialize the graphics window: initwindow(S, S, "At the north pole!"); // 2. Draw six snowmen: draw_snowman(S/5, S/3, S/17); draw_snowman(S/5, 2*S/3, S/50); draw_snowman(int(0.73*S), int(0.64*S), S/6); draw_snowman(int(0.5*S), int(0.43*S), S/10); draw_snowman(int(0.88*S), int(0.12*S), S/73); draw_snowman(int(0.66*S), int(0.1*S), S/39); // 3. Finish: delay(10000); return EXIT_SUCCESS; } //---------------------------------------------------------- //---------------------------------------------------------- void draw_snowman(int x, int y, int radius) { circle(x, y, radius); // Draw the body circle(x, y-3*radius/2, radius/2); // Draw the head } //----------------------------------------------------------