/*Bresenham's Circle Drawing algorithm*/
#include<dos.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<iostream.h>
void main()
{
float d;
int gd,gm,x,y,midx,midy;
int r;
clrscr();
/* Read the radius of the circle
---------------------------------- */
cout<<"\tEnter the radius of a circle :";
cin>>r;
/* Initialise graphics mode
------------------------------*/
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
/* Initialise starting points
-------------------------------*/
x = 0;
y = r;
midx=getmaxx()/2;
midy=getmaxy()/2;
/* initialise the decision variable
---------------------------------------*/
d = 3 - 2 * r;
do
{ putpixel(midx+x,midy+y,BLUE);
putpixel(midx+y,midy+x,GREEN);
putpixel(midx+y,midy-x,RED);
putpixel(midx+x,midy-y,BROWN);
putpixel(midx-x,midy-y,LIGHTGRAY);
putpixel(midx-y,midy-x,LIGHTBLUE);
putpixel(midx-y,midy+x,LIGHTGREEN);
putpixel(midx-x,midy+y,LIGHTRED);
if (d <= 0)
{
d = d + 4*x + 6;
}
else
{
d = d + 4*(x-y) + 10;
y = y - 1;
}
x = x + 1;
delay(50); /* Delay is purposely inserted to see
observe the circle drawing process */
}
while(x < y);
getch();
closegraph();
}
For OUTPUT check out the video! :
#include<dos.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<iostream.h>
void main()
{
float d;
int gd,gm,x,y,midx,midy;
int r;
clrscr();
/* Read the radius of the circle
---------------------------------- */
cout<<"\tEnter the radius of a circle :";
cin>>r;
/* Initialise graphics mode
------------------------------*/
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
/* Initialise starting points
-------------------------------*/
x = 0;
y = r;
midx=getmaxx()/2;
midy=getmaxy()/2;
/* initialise the decision variable
---------------------------------------*/
d = 3 - 2 * r;
do
{ putpixel(midx+x,midy+y,BLUE);
putpixel(midx+y,midy+x,GREEN);
putpixel(midx+y,midy-x,RED);
putpixel(midx+x,midy-y,BROWN);
putpixel(midx-x,midy-y,LIGHTGRAY);
putpixel(midx-y,midy-x,LIGHTBLUE);
putpixel(midx-y,midy+x,LIGHTGREEN);
putpixel(midx-x,midy+y,LIGHTRED);
if (d <= 0)
{
d = d + 4*x + 6;
}
else
{
d = d + 4*(x-y) + 10;
y = y - 1;
}
x = x + 1;
delay(50); /* Delay is purposely inserted to see
observe the circle drawing process */
}
while(x < y);
getch();
closegraph();
}
For OUTPUT check out the video! :
Ps: Please Like and Subscribe--->> https://youtu.be/JR4w_aY9dOs
Need a reliable dishwasher repair service you can trust? Our expert technicians specialize in fast, affordable, and dependable repairs for all major brands. Whether it’s leaking, not draining, or simply won’t start, we’ll get your appliance back in top shape. reliable appliance dishwasher repair service With years of experience and a satisfaction guarantee, we ensure quality workmanship and prompt service every time. Don’t let a broken dishwasher disrupt your routine—call us today for reliable appliance repair you can count on!
ReplyDelete