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.
____________________________________________________
***Figure 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 && lastStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started