Programs Experts Community Question Online Exam ResourceLink Gallery Members Search
Login
Username:
Password:
New user? Sign up
Forgot Password?
Notice
New Category Started

Question, Resource &
Rich Text Editor
for content text input
Invite Friends
Email *
Firstname *
Lastname
 
Programmer Information
View Source Code
flood fill algorithm by hitesh
#include<stdio.h>
    #include<graphics.h>
    #include<dos.h>

    void fill_right(x,y)
    int x , y ;
    {
       if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED))
       {
        putpixel(x,y,RED);
        fill_right(++x,y);
        x = x - 1 ;
        fill_right(x,y-1);
        fill_right(x,y+1);

       }
    }

    void fill_left(x,y)
    int x , y ;
    {
       if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED))
       {
        putpixel(x,y,RED);

        fill_left(--x,y);
        x = x + 1 ;
        fill_left(x,y-1);
        fill_left(x,y+1);

       }
    }
/*------------------------------------------------------*/

    void main()
    {
        int x , y ,a[10][10];
        int gd, gm ,n,i;

        detectgraph(&gd,&gm);
        initgraph(&gd,&gm," ");

        printf("\n\n\tEnter the no. of edges of polygon :  ");
        scanf("%d",&n);
        printf("\n\n\tEnter the cordinates  of  polygon :\n\n\n ");

        for(i=0;i<n;i++)
        {
            printf("\tX%d  Y%d  :  ",i,i);
            scanf("%d %d",&a[i][0],&a[i][1]);
        }

        a[n][0]=a[0][0];
        a[n][1]=a[0][1];

        printf("\n\n\tEnter the seed pt. : ");
        scanf("%d%d",&x,&y);


        cleardevice();
        setcolor(WHITE);

        for(i=0;i<n;i++)  /*- draw poly -*/
        {
             line(a[i][0],a[i][1],a[i+1][0],a[i+1][1]);
        }

        fill_right(x,y);
        fill_left(x-1,y);

        getch();
    }
Views
2

Rating
0

Language
C

Category
Visual C

Compiler
ANSI C

OS
Windows

Last Modified
22nd Jul 10 04:47:42 AM

View Program Documentation
Rating, Comments, Suggestions & Bugs
Additional Feaures

 
© Scodz, 2006 All Rights Reserved. Guest Book | FAQ | Privacy Policy | Terms & Conditions | Contact Us  
Contact Us for Advertising in this website