C Language Graphics Library Reference (part 2)

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.

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

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

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.

Function circle

Draws the circle on the screen using a point(x,y) and the radius for the circle.

Function drawpoly

This function draws an outline of a polygon.

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.

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.

Function outtext

Displays a text string on the grpahics screen.

Function outtextxy

Displays the text at a specified position in graphics mode.

Function putpixel

Prints a pixel at the specified point on the screen.

Function rectangle

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

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.

One Comment

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

Leave a Reply