中点画直线算法 (9)
/* ËÄÏòÁ?Í?ÖÖ×ÓÌî?äµÝ?éËã?? */
#include "Conio.h"
#include "graphics.h"
void seedfilling(int x, int y, int fill_color, int boundary_color)
{
int c;
c=getpixel(x, y); /* ?ñÈ?µ?Ç?µãµÄÑÕÉ? */
if((c!=boundary_color)&&(c!=fill_color)){ /* µ?Ç?µã??ÊÇ?ß?çÉ?ÇÒ??ÊÇÌî?äÉ?, ÔòÌî?ä */
putpixel(x, y, fill_color);
getch(); /* ÏÔÊ?Ìî?ä×?Ì? */
seedfilling(x+1, y, fill_color, boundary_color); /* ËÄÏò?ì?é??????ÐèÒªÌî?äµÄµãÑ?Èë?ÑÕ? */
seedfilling(x-1, y, fill_color, boundary_color);
seedfilling(x, y+1, fill_color, boundary_color);
seedfilling(x, y-1, fill_color, boundary_color);
}
}
void main()
{
int scale=3, poly[10];
int graphdriver=DETECT, graphmode;
initgraph(&graphdriver, &graphmode," ");
poly[0]=100*scale; /* ?à?ßÐεĵÚÒ?µã×ø?ê */
poly[1]=100*scale;
poly[2]=120*scale; /* µÚ?þµã */
poly[3]=110*scale;
poly[4]=110*scale; /* µÚÈýµã */
poly[5]=120*scale;
poly[6]=110*scale; /*µÚËĵã*/
poly[7]=110*scale;
poly[8]=100*scale; /*?à?ßÐεÄÆðµãÓëÖÕµãÒ?Ñù*/
poly[9]=100*scale;
drawpoly(5, poly); /* ÏÔÊ??à?ßÐÎ */
seedfilling(scale*115, scale*110, 4, 15); /*ÖÖ×ÓÌî?ä?à?ßÐÎ*/
closegraph();
}