The other half is in the photos
Read the paint program below carefully and complete the source code paint.cpp by:
/* paint.cpp */
#define LINE 1
#define RECTANGLE 2
#define TRIANGLE 3
#define POINTS 4
#define TEXT 5
#include <stdlib.h>
#include <GL/glut.h>
// global variables
GLsizei wh = 500, ww = 500; // initial window size
GLfloat size = 3.0; // half side length of square
int draw_mode = 0; // drawing mode
int rx, ry; // raster position
GLfloat r = 1.0, g = 1.0, b = 1.0; // drawing color
int fill = 0; // fill flag
// pick function
int pick(int x, int y)
{
y = wh - y;
if(y < wh-ww/10) return 0;
else if(x < ww/10) return LINE;
else if(x < ww/5) return RECTANGLE;
else if(x < 3*ww/10) return TRIANGLE;
else if(x < 2*ww/5) return POINTS;
else if(x < ww/2) return TEXT;
else return 0;
}
// draw square function
void drawSquare(int x, int y)
{
y=wh-y;
glColor3ub( (char) rand()%256, (char) rand()%256, (char) rand()%256);
glBegin(GL_POLYGON);
glVertex2f(x+size, y+size);
glVertex2f(x-size, y+size);
glVertex2f(x-size, y-size);
glVertex2f(x+size, y-size);
glEnd();
}
// mouse event handlers
void mouse(int btn, int state, int x, int y)
{
static int count;
int where;
static int xp[2],yp[2];
if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
where = pick(x,y);
glColor3f(r, g, b);
if(where != 0)
{
count = 0;
draw_mode = where;
}
else
switch(draw_mode)
{
case(LINE):
if(count==0)
{
count++;
xp[0] = x;
yp[0] = y;
}
else
{
glBegin(GL_LINES);
glVertex2i(x,wh-y);
glVertex2i(xp[0],wh-yp[0]);
glEnd();
count=0;
}
break;
case(RECTANGLE):
if(count == 0)
{
count++;
xp[0] = x;
yp[0] = y;
}
else
{
if(fill) glBegin(GL_POLYGON);
else glBegin(GL_LINE_LOOP);
glVertex2i(x,wh-y);
glVertex2i(x,wh-yp[0]);
glVertex2i(xp[0],wh-yp[0]);
glVertex2i(xp[0],wh-y);
glEnd();
count=0;
}
break;
case (TRIANGLE):
switch(count)
{
case(0):
count++;
xp[0] = x;
yp[0] = y;
break;
case(1):
count++;
xp[1] = x;
yp[1] = y;
break;
case(2):
if(fill) glBegin(GL_POLYGON);
else glBegin(GL_LINE_LOOP);
glVertex2i(xp[0],wh-yp[0]);
glVertex2i(xp[1],wh-yp[1]);
glVertex2i(x,wh-y);
glEnd();
count=0;
}
break;
case(POINTS):
{
drawSquare(x,y);
count++;
}
break;
case(TEXT):
{
rx=x;
ry=wh-y;
glRasterPos2i(rx,ry);
count=0;
}
}
glPopAttrib();
glFlush();
}
}
// keyboard input function
void key(unsigned char k, int xx, int yy)
{
if(draw_mode!=TEXT) return;
glColor3f(0.0,0.0,0.0);
glRasterPos2i(rx,ry);
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, k);
rx+=glutBitmapWidth(GLUT_BITMAP_9_BY_15,k);
}
// draw screen box
void screen_box(int x, int y, int s )
{
glBegin(GL_QUADS);
glVertex2i(x, y);
glVertex2i(x+s, y);
glVertex2i(x+s, y+s);
glVertex2i(x, y+s);
glEnd();
}
Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 4 images
- Need help with coding this in python using tkinter Write a GUI program to let the user enter a file name from an entry field and then count the number of occurrences of each letter in that file. Clicking theShow Result button displays the result in a text widget. You need to displaya message in a message box if the file does not exist. https://www.bartleby.com/questions-and-answers/need-help-with-coding-this-in-python-using-tkinter-write-a-gui-program-to-let-the-user-enter-a-file-/153862b8-6d38-47a4-bd38-9c66882021d1arrow_forwardQuestion 14 papa .Full explain this question and text typing work only We should answer our question within 2 hours takes more time then we will reduce Rating Dont ignore this linearrow_forwardChapter 10: Improve number and string formatting Update the program to improve the formatting of the numbers and the strings. Console MENU OPTIONS 1 2 3 4 5 6 7 Display lineup Add player Remove player Move player Edit player position Edit player stats Exit program POSITIONS C, 1B, 2B, 3B, SS, LF, CF, RF, P Menu option: 1 Player 1 Tommy La Stella 2 Mike Yastrzemski 3 Donovan Solano Baseball Team Manager 4 Buster Posey 5 Brandon Belt 6 Brandon Crawford 7 Alex Dickerson 8 Austin Slater 9 Kevin Gausman Menu option: 7 Bye! ============================== POS 3B RF 2B с 1B SS LF CF P AB H 1316 360 0.274 563 168 0.281 1473 407 0.276 0.302 4575 1380 3811 1003 4402 1099 160 147 2 586 569 56 AVG 0.263 0.250 0.273 0.274 0.036 Specifications Use the repetition operator to make sure that horizontal separator lines use 64 characters. • Use spaces, not tabs, to align columns. This should give the program more control over how the columns are aligned. • Make sure the program always displays the batting…arrow_forward
- Please assist to create menu function by using input() in Python. the output is like attached image. if input entered 1 the program keeps going for next question, but if entered option 2 the program should return none. the program I wrote below is only for input option "1" but if entered option 2, I don't know how to stop the program. Thanks. ------------------------------------------------------------------- print('-'*75,'Student Report Menu Options','-'*75,\ '1. Report grade for a student','2. Quit',sep='\n') x = input() print('Please enter the student number: ') y = input()arrow_forwardQUESTION 2 Design a Program “My Oval Factory" that has only one Button to produce Oval. When user clicks on the button, an Oval of random size must be displayed in the JFrame. Program should close on clicking the X button.arrow_forwardYour application will demonstrate the use of a loop to determine the smallest value entered by the user. Incorporate the following requirements into your application: The program will consist of one file - the main application class Name the class appropriately and name the file Program.cs (the default when you create the application) Include documentation at the top of the file that includes Your name Date of development Assignment (e.g., CIS214 Performance Assessment - Smallest Number) Description of the class The main application class must meet the following requirements Print a line that states "Your Name - Week 2 PA Smallest Number" Ask the user how many integers they will enter Loop to get the specified number of integers from the user Print the value of the smallest integer entered by the userarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education