コード例 #1
0
void boundary_fill(int x,int y,int fcolor,int bcolor)
{
	if ((getpixel(x,y)!=fcolor) && (getpixel(x,y)!=bcolor))
	{
		putpixel(x, y, fcolor);
		boundary_fill(x+1,y,fcolor,bcolor);
		boundary_fill(x-1,y,fcolor,bcolor);
		boundary_fill(x,y-1,fcolor,bcolor);
		boundary_fill(x,y+1,fcolor,bcolor);
	}
}
コード例 #2
0
ファイル: vga.c プロジェクト: Ichimonji10/phoenix
/*!
 * Recursive fill using the boundary-fill algorithm. This function should not be called by the
 * user.
 *
 * \param x The x position of the fill (0 to 319).
 * \param y The y position of the fill (0 to 199).
 * \param color The fill color.
 * \param empty_color The color of the area to be filled.
 */
void boundary_fill( int x, int y, byte color, byte empty_color )
{
    if( x > SCREEN_HEIGHT || x < 0 ) { return; }
    if( y > SCREEN_WIDTH  || y < 0 ) { return; }
    if( get_pixel(x, y) == empty_color ) {
        put_pixel(x, y, color);
        boundary_fill( x + 1, y    , color, empty_color );
        boundary_fill( x    , y - 1, color, empty_color );
        boundary_fill( x - 1, y    , color, empty_color );
        boundary_fill( x    , y + 1, color, empty_color );
    }
}
コード例 #3
0
void main()
{
	int x,y,fcolor,bcolor=15;
	int gd = DETECT,gm;
	initgraph(&gd, &gm,"");
	cleardevice();
	line(100,200,500,200);
	line(100,200,50,250);
	line(50,250,150,250);
	line(100,200,150,250);
	line(150,250,550,250);
	line(500,200,550,250);
	rectangle(50,250,150,400);
	rectangle(150,250,550,400);
	circle(100,225,5);
	rectangle(350,300,400,400);
	boundary_fill(60,260,1,15);
	boundary_fill(160,260,12,15);
	boundary_fill(101,226,13,15);
	boundary_fill(360,320,9,15);
	boundary_fill(150,210,3,15);
	boundary_fill(80,230,14,15);
	getch();
}
コード例 #4
0
ファイル: vga.c プロジェクト: Ichimonji10/phoenix
/*!
 * Calls a recursive fill function using color of target pixel as the empty color.
 *
 * \param x The x position of the circle's center (0 to 319).
 * \param y The y position of the circle's center (0 to 199).
 * \param color The color of the circle.
 */
void fill(int x, int y, byte color)
{
    byte far *VGA = MK_FP( 0xA000, 0x0000 );
    boundary_fill( x, y, color, VGA[y * SCREEN_WIDTH + x] );
}