CGMM
CGMM
VISHWAVIDHYALAYA
Subject: CGMM
Subject Code: BTCS503
Submitted to: Prof. Manorama Chouhan
CGMM LAB FILE
Q1. What is Graphic.h?
Graphics programming in C used to drawing various geometrical shapes (rectangle, circle
eclipse etc), use of mathematical function in drawing curves, colouring an object with different
colours and patterns and simple animation programs like jumping ball and moving cars. There
are the following functions: -
1. ARC- "arc" function is used to draw an arc with centre (x, y) and ‘strangle’ specifies
starting angle, ‘endangle’ specifies the end angle and last parameter specifies the
radius of the arc. arc function can also be used to draw a circle but for that starting
angle and end angle should be 0 and 360 respectively.
2. BAR- Bar function is used to draw a 2-dimensional, rectangular filled in bar.
Coordinates of left top and right bottom corner are required to draw the bar. Left
specifies the X- coordinate of top left corner, top specifies the Y-coordinate of top left
corner, right specifies the X-coordinate of right bottom corner, bottom specifies the Y-
coordinate of right bottom corner. Current fill pattern and fill colour is used to fill the
bar.
3. CIRCLE - Circle function is used to draw a circle with centre (x, y) and third
parameter specifies the radius of the circle.
6. LINE - line function is used to draw a line from a point (x1, y1) to point (x2, y2) i.e. (x1,
y1) and (x2, y2) are end points of the line.
Syntax: void line (int x1, int y1, int x2, int y2);
7. ELLIPSE- Ellipse is used to draw an ellipse (x, y) are coordinates of centre of the
ellipse, ‘stangle’ is the starting angle, ‘end angle’ is the ending angle, and fifth and
sixth parameters specifies the X and Y radius of the ellipse. To draw a complete ellipse
strangles and end angle should be 0 and 360 respectively.
Syntax: void ellipse (int x, int y, int stangle, int endangle, int x-radius, int y-radius);
8. FILLELLIPSE- x and y are coordinates of centre of the ellipse, x-radius and y-radius are x
and y radius of ellipse respectively.
Syntax: void fillellipse (int x, int y, int x-radius, int y-radius);
Q2. PutPixel Function
Putpixel function plots a pixel at location (x, y) of specified colour. For example, if we want to
draw a GREEN coloured pixel at (35, 45) then we will write putpixel (35, 35, GREEN). In c
programs, putpixel function can be used to draw circles, lines and ellipses using various
algorithms.
Q3. Graphic Image using PutPixel.
Q4. Use minimum 10 graphic functions to create something creative.
Q5. Implementation of DDA line drawing algorithm.
Q6. Implementation of Bresenham’s Line Drawing Algorithms.
Q7. Mid-Point circle drawing theorem.
Q8. Bresenhams Circle drawing algorithm