Circle and Line Function in Computer Graphics

Hello Guys,
Circle Function:-

 Declaration: void circle(int x, int y, int radius);
Circle function is used to draw a circle with center (x,y) and third parameter specifies the radius of the circle. The code given below draws a circle.

C program for circle

#include<graphics.h>
#include<conio.h>
void main()
{
   int gd = DETECT, gm;
   initgraph(&gd, &gm, "C:\\TC\\BGI");
   circle(100, 100, 50);
 
   getch();
   closegraph();
   return 0;
}
In the above program (100, 100) are coordinates of center of the circle and 50 is the radius of circle.

Line Function:-

Line function is used to draw a line from a point(x1,y1) to point(x2,y2) i.e. (x1,y1) and (x2,y2) are end points of the line.The code given below draws a line.
Declaration: void line(int x1, int y1, int x2, int y2);

C programming code for line

#include <graphics.h>
#include <conio.h>
void main()
{
   int gd = 0, gm;
   initgraph(&gd, &gm, "C:\\TC\\BGI");
   line(100, 100, 200, 200);
   getch();
   closegraph();
   return 0;
}
Above program draws a line from (100, 100) to (200, 200).

Comments

Post a Comment

Popular posts from this blog

Applications of Computer Graphics

Scan Conversion in Computer Graphics

Components of Computer Graphics