/* CPSC 360 Programming Assignment 3 * Letters of the alphabet * by Chris Bolduc * boldu101@chapman.edu */ #include "letters.h" // I have these includes in my header file. Uncomment them if you don't. //#include //#include //#include #ifndef PI #define PI 3.141592653579 #endif // Draws the letter F void draw_f(){ draw_F(); } void draw_F(){ glBegin(GL_LINES); glVertex2f(0.1, 0.0); glVertex2f(0.1, 1.0); glVertex2f(0.1, 1.0); glVertex2f(0.9, 1.0); glVertex2f(0.1, 0.5); glVertex2f(0.9, 0.5); glEnd(); glTranslated(1, 0, 0); } // Draws the letter P void draw_p(){ draw_P(); } void draw_P(){ int NUM_LINES = 20; float xcoord, ycoord, i; float l = 0.30; glBegin(GL_LINES); glVertex2f(0.10, 0.00); glVertex2f(0.10, 1.00); glVertex2f(0.10, 1.00); glVertex2f(0.33, 1.00); glVertex2f(0.33, 0.40); glVertex2f(0.10, 0.40); glEnd(); // Draw a semicircle glTranslated(0.30, 0.70, 0); glBegin(GL_LINE_STRIP); for(i = -NUM_LINES / 4; i <= NUM_LINES / 4; ++i){ xcoord = l * cos(i*2*PI/NUM_LINES); ycoord = l * sin(i*2*PI/NUM_LINES); glVertex2f(xcoord, ycoord); } glEnd(); glTranslated(-0.30, -0.70, 0); glTranslated(0.7, 0, 0); } // Draws the letter Z void draw_z(){ draw_Z(); } void draw_Z(){ glBegin(GL_LINE_STRIP); glVertex2f(0.1, 1.0); glVertex2f(0.9, 1.0); glVertex2f(0.1, 0.0); glVertex2f(0.9, 0.0); glEnd(); glTranslated(1, 0, 0); }