Graphics Functions in C

rectangle() Function: It is used to draw a rectangle by specifying the diagonal coordinates. It has the following syntax:

rectangle(x1, y1, x2, y2); // where x1 and y1 are integers representing the top-left coordinates of the rectangle. x2 and y2 are integers representing the bottom-right coordinates of the rectangle.

circle() Function: It is used to draw a circle by specifying its center and radius. It has the following syntax:

circle(x, y, r)

arc() Function: This function is used to draw a circular arc by specifying the centre, radius and starting and ending angles. It has the following syntax:

arc(x, y, as, ea, r)

ellipse() Function: This function is used to draw an ellipse by specifying the centre, radius, start and end angles and the semi-major and semi-minor axes of the ellipse. It has the following syntax:

ellipse(x, y, as, ea, xr, yr);

pieslice() Function: This function is similar to an arc() function. It is used to draw an arc along with the two radii lines forming the slice or sector of the circle. It has the following syntax:

pieslice(x,y, sa, ca, r);

bar() Function: It is used to draw a rectangular bar using the diagonally opposite corners and fill it with current fill style and colour. It has the following syntax:

bar(x1, y1, x2, y2);

bar3d() Function: This function is used to draw a three-dimensional view of a rectangular bar using the diagonally opposite corners of a rectangle with specified depth.

cleardevice() Function: It is used to clear the screen in graphics mode. It has the following syntax:

cleardevice();

setlinestyle() Function: It is used to set a new line style. It has the following syntax:

setlinestyle(m, n, t);

setfillstyle() Function:This function is used to fill a closed boundary by a pattern. It has the following syntax:

setfillstyle(m, c);

setfillpattern() Function: This function is used to create a user-defined fill pattern. It has the following syntax:

setfillpattern(pn, c)

floodfill() Function: This function is used to fill an area with any required style. The area should have closed boundary lines. It has the following syntax:

floodfill(m,n,c);