Graphic Functions

Initializing Graphics

First of all you need to initialize graphic driver and mode to enable graphic functions.
#include <graphics.h>
void main()
{
int driver=DETECT,mode;
initgraph(&driver,&mode,"..\bgi"); \where "..\bgi" is the path of bgi files
}

Line

Creates a line on the screen.
line(x1,y1,x2,y2);

Circle

Draws a circle on the screen
circle(x,y,radius);

arc(midx, midy, stangle, endangle, radius)

To draw an arc.

closegraph()

Deallocates all memory used up by graphic functions.

getmaxx(), getmaxy()

getmaxx() --> Returns the x resolution.
getmaxy() --> Returns the y resolution

rectangle(int, int, int, int)

Draws a rectangle on the screen.
Syntax.
rectangle(p1x, p1y, p2x, p2y);
p1 and p2 are any 2 opposite points of the rectangle.

setcolor(int color)

Sets the object color.
See color codes also.

setfillstyle(int type, int fillcolor)

sets the fill pattern and fill color of fallible objects.

fillellipse(midx,midy,r1,r2)

Draws a color filled ellipse on the screen.
r1 and r2 are the 2 radius of ellipse
ex.
setcolor(9);
setfillstyle(1,12);
fillellipse(60,60,5,5);
//Draws an ellipse of boundary color BLUE and filled with Light Red color.
c++ source codes