Advertisement
MHSS

BoundaryFill

May 1st, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<conio.h>
  4. #include<graphics.h>
  5. void bound(int x,int y,int fillcolor,int bcolor){
  6.     int color=getpixel(x,y);
  7.     if(color!=fillcolor && color != bcolor){
  8.         putpixel(x,y,fillcolor);
  9.         bound(x+1,y,fillcolor,bcolor);
  10.         bound(x-1,y,fillcolor,bcolor);
  11.         bound(x,y-1,fillcolor,bcolor);
  12.         bound(x,y+1,fillcolor,bcolor);
  13.     }
  14. }
  15.  
  16. void main(){
  17.     clrscr();
  18.     int gd=DETECT,gm;
  19.     initgraph(&gd,&gm,"C:\\TC\\bgi");
  20.     line(300,300,350,300);
  21.     line(300,300,300,350);
  22.     line(300,350,350,350);
  23.     line(350,300,350,350);
  24.     bound(310,310,MAGENTA,BLUE);
  25.     getch();
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement