0% found this document useful (0 votes)
29 views10 pages

Introduction To Computer Graphics and Visualization

Uploaded by

ps9473013
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views10 pages

Introduction To Computer Graphics and Visualization

Uploaded by

ps9473013
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Introduction to Computer

Graphics and Visualization


By
Vaibhav P. Vasani
Assistant Professor
Department of Computer Engineering
K. J. Somaiya College of Engineering
Somaiya Vidyavihar University
Line Drawing using moveto() and
lineto().
• moveto(x, y) set CP to (x, y)
• lineto(x, y) draw a line from CP to (x, y), and then update CP to (x, y)

• A line from (x1, y1) to (x2, y2) is therefore drawn using the two calls moveto(x1,
y1);lineto(x2,y2). A polyline based on the list of points (x0 , y 0), (x1, y1), ... , (xn-
1, yn-1) is easily drawn

• GLintPoint CP // global current position


Practice Questions
• Drawing Aligned Rectangles
• A special case of a polygon is the aligned rectangle, so called because
its sides are aligned with the coordinate axes.
• Drawing the checkerboard.
Mouse interaction
• function myMouse() to take four parameters, so that it has the
prototype:
• void myMouse(int button, int state, int x, int y);
• Event occurs the system calls the registered function, supplying
it with values for these parameters. The value of button will be
one of:
• GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, or
GLUT_RIGHT_BUTTON,
Example: Placing dots with the
mouse
• Each time the user presses down the left mouse button a dot is drawn in
the screen window at the mouse position. If the user presses the right
button the program terminates.

• the y-value of the mouse position is the number of pixels from the top of
the screen window, we draw the dot, not at (x, y), but at (x, screenHeight –
y), where screenHeight is assumed here to be the height of the window in
pixels.
Practice Question
• Specifying a rectangle with the mouse
• Create a polyline using the mouse
• “Freehand” drawing with a fat brush***
Case Study
• Pseudo random Clouds of Dots

• The Gingerbread Man.


• . The Golden Ratio

• Polyline Editor.

You might also like