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 graphics functions to draw different 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.

1 |
void 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

1 |
void 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

1 |
void 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 Dimensional 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.

1 |
void 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.

1 |
void circle(int x, int y, int radius) |

### Function drawpoly()

This function draws an outline of a polygon.

1 |
void 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.

1 |
void 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.

1 |
void floodfill(int x, int y, int border) |

### Function outtext()

Displays a text string on the screen in graphics mode.

1 |
void outtext(char far *str) |

### Function outtextxy()

Displays the text at a specified position in graphics mode.

1 |
void outtext(int x, int y, char *str) |

### Function putpixel()

Prints a pixel at the specified point on the screen.

1 |
void putpixel(int x, int y, int color) |

### Function rectangle()

Draws a rectangular box on the screen using the points given in the parameters.

1 |
void rectangle(int left, int top, int right, int bottom) |

I hope this explanation of common 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.

What does the parameter int border mean in floodfill function?

Please can you explain by writing a simple code to draw a rectangle and fill it up with a color so that I can understand what you’re trying to explain?

Please can you do it as soon as possible as I’ve an assignment on this to be submitted in two days?

This explanation is very useful indeed and I thank you for helping students like me learn basics!!