In the previous post I discussed few important functions mostly used to initialize and destroy the graphics mode in DOS environment. Today I will discuss functions to draw diferent shapes and lines. So here we go by starting the line function which is most important function in creating any graphics.
Function line
This function draws a line in the graphics mode.
void far line(int startx, int starty, int endx, int endy)
Function arc
This function draws an arc from start to the end point. It uses the radius and the angle inputted in the function parametsr. Function prototye is
void far arc (int x, int y, int start, int end, int radius)
Function bar
The bar() functions draws a rectangular bar on the screen. It takes four parameters of type int which are infact the points on the graphics screen, and fills the bar with the defined fill-pattern. Function prototye is
void far bar(int left, int top, int right, int bottom)
Here left & top are the starting point for the rectangular bar from x and y coordinates respectively and right & bottom are the ending point.
Function bar3d
As the name suggests that this function will draw the 3 Dimentional rectangular bar on the screen. Bar3d function takes six parameters of which four are the points , fifth one is the depth of the bar and sixth is the flag to indicate the 3D view. Here is the prototype of the bar3d function.
void far bar3d(int left, int top, int right, int bottom, int depth, int topflag)
Function circle
Draws the circle on the screen using a point(x,y) and the radius for the circle.
void far circle(int x, int y, int radius)
Function drawpoly
This function draws an outline of a polygon.
void far drawpoly(int numpoints, int far *points)
Here numpoints is the number of end points in the polygon. And points is the integer array which contains the x and y coordinates of the points.
Function ellipse
Draws an ellipse using the current drawing color.
void far ellipse(int x, int y, int start, int end, int xradius, int yradius)
Function floodfill
This function fills an object drawn on the graphics screen with the defined color and fill pattern. Now if the x,y coordinates lie within the boundries of the object then it will fill the interior of the object otherwise out side the object.
void far floodfill(int x, int y, int border)
Function outtext
Displays a text string on the grpahics screen.
void far outtext(char far *str)
Function outtextxy
Displays the text at a specified position in graphics mode.
void far outtext(int x, int y, char *str)
Function putpixel
Prints a pixel at the specified point on the screen.
void far putpixel(int x, int y, int color)
Function rectangle
Draws a rectangular box on the screen using the points given in the parameters.
void far rectangle(int left, int top, int right, int bottom)
I hope this explanation of commom functions present in graphics.h library would help you learn graphics programming in C language. If you guys need any help, you are most welcome to ask and I would try to help you guys out.
In the next few days I will write a sample program which will demonstrate the use of these functions as well as the way to initialize the graphics mode in c programming language.