How to Write C Code for Object Drawing in Computer Graphics?
Steps to be followed:
•Draw
rough outline of Object on paper.
•Identify
graphics primitives required for drawing the object.
•Find
command from graphics library to draw the object.
•Find
Coordinates of graphics primitives with respect to Object and Computer Screen.
Functions required from graphics library of C language:
•Circle:
circle(int x, int y, int radius);
•Ellipse:ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);
•Line:line(int x1, int y1, int x2, int y2)
•Rectangle:rectangle(int left, int top, int right, int bottom)
•Arc: arc(int x, int y, int stangle, int endangle, int radius);
•Fill
ellipse: fillellipse(int x, int y, int xradius, int yradius)
•To
set color of primitives : setcolor(int color);
•To
set background
color :setbkcolor(int color)
Calculate points with respect to xy coordinates as shown below.
see following video for implementation: