Drawing Circle in Graphics Mode - Graphics Programs

Drawing Circle in Graphics Mode.


C Program to Drawing Circle in Graphics Mode-Images-Pictures-Photos-Snaps-Basic C Programs-C Language Programs-C Program to draw a Circle in Graphics Mode-General C Programs-Program for Circle-Circle Program-Graphics Programs.

Computer graphics is an art of drawing pictures, lines, charts, etc using computers with the help of programming. Computer is made up of number of pixels.

In this program we first initialize graphics mode, by passing graphics driver(DETECT), default graphics mode and specifies the directory path where initgraph looks for graphics drivers (* BGI).

Setting graphics driver as DETECT, means instructing the compiler to auto detect graphics driver.

Graphics functions used in this program are:

1. initgraph - It initializes the graphics system by loading the passed graphics driver then changing the system into graphics mode.

2. getmaxx - It returns the maximum X coordinate in current graphics mode and driver.

3. getmaxy - It returns the maximum Y coordinate i current graphics mode and driver.

4. outtextxy - It displays a string at a particular point(x,y) on screen.

5. circle - It draws a circle with radius r and center at(x,y).

6. closegraph - It unloads the graphics drivers and sets the screen back to text mode.


--------------------------------------------------------------------------------------------------------------------------

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int main( )
{
   int gd = DETECT,gm;
   int x, y, radius = 60;
   initgraph(&gd, &gm, "c:\\tc\\bgi");
   x = getmaxx( )/2;
   y = getmaxy( )/2;
   outtextxy(x-200,100,"CIRCLE using Graphics in C");
   circle(x,y,radius);
   getch( );
   closegraph( );
   return 0;
}

--------------------------------------------------------------------------------------------------------------------------

Output

--------------------------------------------------------------------------------------------------------------------------

Displays Circle


EmoticonEmoticon