Question: COMPUTER GRAPHICS --- The Figures just a hint to write a new code ***Figure 2.40. ____________________________________________________ ***Figure 2.41. ___________________________________ ******See Fig. 2.40. and 2.41., and

COMPUTER GRAPHICS --- The Figures just a hint to write a new code

***Figure 2.40.

COMPUTER GRAPHICS --- The Figures just a hint to write a new

____________________________________________________

***Figure 2.41.

code ***Figure 2.40. ____________________________________________________ ***Figure 2.41. ___________________________________ ******See Fig. 2.40. and 2.41.,

___________________________________

******See Fig. 2.40. and 2.41., and create a "freehand" drawing program. Write the program and name your source code as freehand.cpp.

Requirement: Let the user interactively draw a freehand curve on the screen (by mouse

movement with left button down). The curve should be drawn only when the left mouse button

is held down. Pressing the right mouse button clears the screen and lets the user start over.

Make sure the curve drawn by the user is connected (it shouldn't have a gap anywhere no matter

how fast the user moves the mouse).

Figure 2.40 shows one possible implementation. Note that last keeps track of the last index used so far in the array List[];it is incremented as each new point is clicked, and set to -1 to make the lists empty. If it were desirable to make use of the points in List outside of myMouse), the variable List could be made global void myMouse (int button, int state, int x, int y) #de fine NUM 20 static GLintPoint List [NUM] static int last = -1; // last index used so far // test for mouse button as well as for a full array if (button == GLUT LEFT BUTTON && state == GLUT DOWN && last

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!