#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>

void bre_circle(int x,int y,int rad);
void display_data(int,int,int,int);

void main()
{
int gd = DETECT, gm, x,y,rad;
initgraph(&gd,&gm,”c:\\tc\\bgi”); //Initialization of graphics driver
cout<<” Algorithm For Bresenhams circle “<<“\n”;
cout<<“Enter the coordinates for Axis “<<“\n”;
cin>>x>>y;
cout<<“Enter the radius of circle”<<“\n”;
cin>>rad;
bre_circle(x,y,rad);
getch();
closegraph();
}
void bre_circle(int x,int y,int rad)
{
float dp;//taking desicion parameter
int x1,y1;
x1 = 0; //initialization of X and Y coordinates.
y1 = rad;
dp = 3 – 2*rad;
while(x1<=y1)
{
if(dp<=0)
{
dp = dp+ (4 * x1) + 6;
}
else
{
dp = dp+ 4*(x1-y1)+10;
y1–;
}
x1++;
display_data(x1,y1,x,y);
}
}
void display_data(int x1,int y1,int x,int y)
{
putpixel(x1+x,y1+y,RED); //plotting the pixels.
putpixel(x-x1,y1+y,RED);
putpixel(x-x1,y-y1,RED);
putpixel(x+y1,y+x1,RED);
putpixel(x+y1,y-x1,RED);
putpixel(x-y1,y+x1,RED);
putpixel(x-y1,y-x1,RED);
}

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

©2018 MYBSCIT.com. An initiative by some failures to make student scholars.

or

Log in with your credentials

Forgot your details?