Program to draw a circle using Mid-point circle drawing Algorithm & Boundary fill Algorithm
- Get link
- X
- Other Apps
#include<iostream>
#include<graphics.h>
using namespace std;
void circleMidpoint(int,int,int);
void BoundaryFill_4_Connected(int,int,int,int);
int main()
{
int xc,yc,r;
cout<<"Enter center coordinate of circle: ";
cin>>xc>>yc;
cout<<"Enter radius of circle: ";
cin>>r;
int gd=DETECT,gm;
char path[] = "";
initgraph(&gd,&gm,path);
circleMidpoint(xc,yc,r);
BoundaryFill_4_Connected( xc, yc, BLUE, WHITE);
getch();
closegraph();
return 0;
}
void circleMidpoint(int xc,int yc,int r)
{
int x=0,y=r,P;
P= 1-r;
while(x<y)
{
putpixel(xc+x, yc+y, WHITE);
putpixel(xc-x, yc+y, WHITE);
putpixel(xc+x, yc-y, WHITE);
putpixel(xc-x, yc-y, WHITE);
putpixel(xc+y, yc+x, WHITE);
putpixel(xc-y, yc+x, WHITE);
putpixel(xc+y, yc-x, WHITE);
putpixel(xc-y, yc-x, WHITE);
if(P<0)
{
P = P+(2*x)+1;
x++;
}
else
{
P=P+2*(x-y)+1;
x++;
y--;
}
}
}
void BoundaryFill_4_Connected(int x,int y,int f_color,int b_color)
{
int current = getpixel(x,y);
if(current != b_color && current != f_color)
{
putpixel(x,y,f_color);
BoundaryFill_4_Connected( x+1, y, f_color, b_color);
BoundaryFill_4_Connected( x-1, y, f_color, b_color);
BoundaryFill_4_Connected( x, y+1, f_color, b_color);
BoundaryFill_4_Connected( x, y-1, f_color, b_color);
}
}
OUTPUT:
- Get link
- X
- Other Apps
Comments
Program To Draw A Circle Using Mid-Point Circle Drawing Algorithm And Boundary Fill Algorithm >>>>> Download Now
ReplyDelete>>>>> Download Full
Program To Draw A Circle Using Mid-Point Circle Drawing Algorithm And Boundary Fill Algorithm >>>>> Download LINK
>>>>> Download Now
Program To Draw A Circle Using Mid-Point Circle Drawing Algorithm And Boundary Fill Algorithm >>>>> Download Full
>>>>> Download LINK yB