Embed presentation
Downloaded 10 times
![/*
Title: Boundary Filling Algorithm
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 20150323
*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include"D:/GP/header/grap.h"
double x[]={20,40,40,20};
double y[]={20,20,40,40};
int points=4;
int boundaryColor=15;
int fillColor=10;
void drawPolygon()
{
int i,j;
for(i=0;i<points;i++)
{
j=(i+1)%points;](https://image.slidesharecdn.com/floodfill-150324230909-conversion-gate01/75/Boundary-Fill-Algorithm-in-C-1-2048.jpg)
![line(x[i],y[i],x[j],y[j]);
}
}
void fill4(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{
putpixel(x,y,fillColor);
fill4(x+1,y);
fill4(x-1,y);
fill4(x,y+1);
fill4(x,y-1);
}
}
void fill8(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{
putpixel(x,y,fillColor);](https://image.slidesharecdn.com/floodfill-150324230909-conversion-gate01/75/Boundary-Fill-Algorithm-in-C-2-2048.jpg)


This document contains code for a boundary filling algorithm. It defines arrays for the x and y coordinates of a polygon with 4 points. It includes functions to draw the polygon, fill it using a 4-connected algorithm, and fill it using an 8-connected algorithm. The main function initializes graphics, draws the polygon in a boundary color, fills it using the 4-connected approach, and ends the program.
![/*
Title: Boundary Filling Algorithm
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 20150323
*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include"D:/GP/header/grap.h"
double x[]={20,40,40,20};
double y[]={20,20,40,40};
int points=4;
int boundaryColor=15;
int fillColor=10;
void drawPolygon()
{
int i,j;
for(i=0;i<points;i++)
{
j=(i+1)%points;](https://image.slidesharecdn.com/floodfill-150324230909-conversion-gate01/75/Boundary-Fill-Algorithm-in-C-1-2048.jpg)
![line(x[i],y[i],x[j],y[j]);
}
}
void fill4(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{
putpixel(x,y,fillColor);
fill4(x+1,y);
fill4(x-1,y);
fill4(x,y+1);
fill4(x,y-1);
}
}
void fill8(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{
putpixel(x,y,fillColor);](https://image.slidesharecdn.com/floodfill-150324230909-conversion-gate01/75/Boundary-Fill-Algorithm-in-C-2-2048.jpg)
