[求助]求图形填充的代码
请问怎么用扇形填充或蔓延填充来填充一个圆?
拿这个圆为例,怎么填充呢。
#include<graphics.h>
#include<string.h>
#include<stdio.h>
void circlePoint(int x,int y)
{
putpixel(x+300,y+300,5);
putpixel(y+300,x+300,5);
putpixel(-y+300,x+300,5);
putpixel(-x+300,y+300,5);
putpixel(-x+300,-y+300,5);
putpixel(-y+300,-x+300,5);
putpixel(y+300,-x+300,5);
putpixel(x+300,-y+300,5);
}
void MidBresenhamcircle(int r)
{
int x,y,d;
x=0;y=r;d=1-r;
while(x<y){
circlePoint(x,y);
if(d<0)d+=2*x+3;
else{
d+=2*(x-y)+5;
y--;
}
x++;
}
}
main()
{
int gdriver=DETECT,gmode,k;
initgraph(&gdriver,&gmode," ");
scanf("%d",&k);
MidBresenhamcircle(k);
getch();
}