SlideShare a Scribd company logo
/*
Title: Flood 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;
int newColor=7;
void drawPolygon()
{
int i,j;
for(i=0;i<points;i++)
{
j=(i+1)%points;
line(x[i],y[i],x[j],y[j]);
}
}
void bfill4(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{
putpixel(x,y,fillColor);
bfill4(x+1,y);
bfill4(x-1,y);
bfill4(x,y+1);
bfill4(x,y-1);
}
}
void bfill8(int x,int y)
{
int currentColor=getpixel(x,y);
if((currentColor!=boundaryColor) && (currentColor!=fillColor))
{
putpixel(x,y,fillColor);
bfill8(x+1,y);
bfill8(x-1,y);
bfill8(x,y+1);
bfill8(x,y-1);
bfill8(x+1,y+1);
bfill8(x-1,y+1);
bfill8(x+1,y-1);
bfill8(x-1,y-1);
}
}
void ffill4(int x,int y)
{
int currentColor=getpixel(x,y);
if(currentColor==fillColor)
{
putpixel(x,y,newColor);
ffill4(x+1,y);
ffill4(x-1,y);
ffill4(x,y+1);
ffill4(x,y-1);
}
}
void ffill8(int x,int y)
{
int currentColor=getpixel(x,y);
if(currentColor==fillColor)
{
putpixel(x,y,newColor);
ffill8(x+1,y);
ffill8(x-1,y);
ffill8(x,y+1);
ffill8(x,y-1);
ffill8(x+1,y+1);
ffill8(x-1,y+1);
ffill8(x+1,y-1);
ffill8(x-1,y-1);
}
}
void main()
{
ginit();
setcolor(15);
drawPolygon();
/*boundary filling algorithm*/
//bfill4(30,30);
bfill8(30,30);
/*flood filling algorithm*/
//ffill4(30,30);
ffill8(30,30);
getch();
gexit();
}

More Related Content

DOCX
Boundary Fill Algorithm in C
Kasun Ranga Wijeweera
 
DOCX
Write a program to perform translation.
Shobhit Saxena
 
DOCX
Binary addition using class concept in c++
Swarup Boro
 
DOCX
Write a program to perform translation
Shobhit Saxena
 
DOCX
1 (1)
Krish Na
 
PPTX
Array matrix example programs - C language
Sk_Group
 
DOCX
[程式設計]Blackfriday
Hui-Shih Leng
 
Boundary Fill Algorithm in C
Kasun Ranga Wijeweera
 
Write a program to perform translation.
Shobhit Saxena
 
Binary addition using class concept in c++
Swarup Boro
 
Write a program to perform translation
Shobhit Saxena
 
1 (1)
Krish Na
 
Array matrix example programs - C language
Sk_Group
 
[程式設計]Blackfriday
Hui-Shih Leng
 

What's hot (13)

PDF
Bcsl 033 data and file structures lab s2-2
Dr. Loganathan R
 
DOC
Ffffffffffff
mohdshanu
 
PDF
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
DOCX
Program for pyramid
nayakq
 
DOCX
2 d rotation
Chandu Kumare
 
DOCX
Answers+of+C+sample+exam.docx
ismailaboshatra
 
DOCX
analog clock C#
omeed
 
PDF
Digital Differential Analyzer Line Drawing Algorithm in C
Kasun Ranga Wijeweera
 
DOCX
Dti2143 lab sheet 9
alish sha
 
DOCX
Aval expres
Elisane Della Costa
 
PDF
Dfs implementation in c
HapPy SumOn
 
PDF
C programs Set 2
Koshy Geoji
 
Bcsl 033 data and file structures lab s2-2
Dr. Loganathan R
 
Ffffffffffff
mohdshanu
 
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
Program for pyramid
nayakq
 
2 d rotation
Chandu Kumare
 
Answers+of+C+sample+exam.docx
ismailaboshatra
 
analog clock C#
omeed
 
Digital Differential Analyzer Line Drawing Algorithm in C
Kasun Ranga Wijeweera
 
Dti2143 lab sheet 9
alish sha
 
Aval expres
Elisane Della Costa
 
Dfs implementation in c
HapPy SumOn
 
C programs Set 2
Koshy Geoji
 
Ad

Viewers also liked (14)

PDF
Computing the Area of a Polygon
Kasun Ranga Wijeweera
 
PDF
Classes and objects
Kasun Ranga Wijeweera
 
PPTX
Improving the accuracy of k-means algorithm using genetic algorithm
Kasun Ranga Wijeweera
 
PDF
Methods in Java
Kasun Ranga Wijeweera
 
PDF
Exercises for Two Dimensional Geometric Transformations
Kasun Ranga Wijeweera
 
PDF
Linked List Implementation of Stack in C
Kasun Ranga Wijeweera
 
PDF
Exercises for Convexity of Polygons
Kasun Ranga Wijeweera
 
PDF
Access modifiers
Kasun Ranga Wijeweera
 
DOCX
Implementation of k-means clustering algorithm in C
Kasun Ranga Wijeweera
 
PDF
Principles of Object Oriented Programming
Kasun Ranga Wijeweera
 
PDF
Linked List Implementation of Deque in C
Kasun Ranga Wijeweera
 
PPTX
Digital Differential Analyzer Line Drawing Algorithm
Kasun Ranga Wijeweera
 
PDF
Linked List Implementation of Queue in C
Kasun Ranga Wijeweera
 
Computing the Area of a Polygon
Kasun Ranga Wijeweera
 
Classes and objects
Kasun Ranga Wijeweera
 
Improving the accuracy of k-means algorithm using genetic algorithm
Kasun Ranga Wijeweera
 
Methods in Java
Kasun Ranga Wijeweera
 
Exercises for Two Dimensional Geometric Transformations
Kasun Ranga Wijeweera
 
Linked List Implementation of Stack in C
Kasun Ranga Wijeweera
 
Exercises for Convexity of Polygons
Kasun Ranga Wijeweera
 
Access modifiers
Kasun Ranga Wijeweera
 
Implementation of k-means clustering algorithm in C
Kasun Ranga Wijeweera
 
Principles of Object Oriented Programming
Kasun Ranga Wijeweera
 
Linked List Implementation of Deque in C
Kasun Ranga Wijeweera
 
Digital Differential Analyzer Line Drawing Algorithm
Kasun Ranga Wijeweera
 
Linked List Implementation of Queue in C
Kasun Ranga Wijeweera
 
Ad

Similar to Flood Filling Algorithm in C (20)

PPTX
CG_U2_M2.pptx
ssuser255bf1
 
PPTX
#KPC #CST #Polygon Fill
KEIKolkata
 
PPTX
#KPC #CST #Polygon fill
KEIKolkata
 
PPT
Unit-2 PPT.ppt
GopalaKrishnanChandr7
 
PPTX
Computer Graphics2 for engineering students.pptx
yoshuaImmanuel1
 
PPT
Seed filling algorithm
Mani Kanth
 
PPTX
FLOOD FILL algorithm in computer graphics.pptx
dheerajsoni645
 
PPTX
Polygon
Ashutoshchoudhary25
 
PDF
Computer Graphics Pollygon filling Techniques.pdf
tabbu23
 
PDF
Polygon Filling method by computer science.pdf
himanshumis2022
 
PPT
Polygon filling
Ankit Garg
 
PPTX
Polygon filling algorithm
Aparna Joshi
 
PPTX
CA301_CG_Filled Area Primitives-New.pptx
KaushikiJha3
 
DOCX
Graphics point clipping c program
Dr.M.Karthika parthasarathy
 
PPT
Fill area algorithms
Kumar
 
PPT
Lecture filling algorithms
avelraj
 
PPTX
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION By Sintiak Haque
SintiakHaque
 
DOCX
Computer graphics question for exam solved
Kuntal Bhowmick
 
PPTX
CS401_M2_L6_Solid Area Scan Conversion.pptx
lara333479
 
PPTX
UNIT2.pptx
ShwetaShah754701
 
CG_U2_M2.pptx
ssuser255bf1
 
#KPC #CST #Polygon Fill
KEIKolkata
 
#KPC #CST #Polygon fill
KEIKolkata
 
Unit-2 PPT.ppt
GopalaKrishnanChandr7
 
Computer Graphics2 for engineering students.pptx
yoshuaImmanuel1
 
Seed filling algorithm
Mani Kanth
 
FLOOD FILL algorithm in computer graphics.pptx
dheerajsoni645
 
Computer Graphics Pollygon filling Techniques.pdf
tabbu23
 
Polygon Filling method by computer science.pdf
himanshumis2022
 
Polygon filling
Ankit Garg
 
Polygon filling algorithm
Aparna Joshi
 
CA301_CG_Filled Area Primitives-New.pptx
KaushikiJha3
 
Graphics point clipping c program
Dr.M.Karthika parthasarathy
 
Fill area algorithms
Kumar
 
Lecture filling algorithms
avelraj
 
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION By Sintiak Haque
SintiakHaque
 
Computer graphics question for exam solved
Kuntal Bhowmick
 
CS401_M2_L6_Solid Area Scan Conversion.pptx
lara333479
 
UNIT2.pptx
ShwetaShah754701
 

More from Kasun Ranga Wijeweera (20)

PDF
Decorator Design Pattern in C#
Kasun Ranga Wijeweera
 
PDF
Singleton Design Pattern in C#
Kasun Ranga Wijeweera
 
PDF
Introduction to Design Patterns
Kasun Ranga Wijeweera
 
PPTX
Algorithms for Convex Partitioning of a Polygon
Kasun Ranga Wijeweera
 
PDF
Geometric Transformations II
Kasun Ranga Wijeweera
 
PDF
Geometric Transformations I
Kasun Ranga Wijeweera
 
PDF
Introduction to Polygons
Kasun Ranga Wijeweera
 
PDF
Bresenham Line Drawing Algorithm
Kasun Ranga Wijeweera
 
PDF
Digital Differential Analyzer Line Drawing Algorithm
Kasun Ranga Wijeweera
 
PDF
Loops in Visual Basic: Exercises
Kasun Ranga Wijeweera
 
PDF
Conditional Logic: Exercises
Kasun Ranga Wijeweera
 
PDF
Getting Started with Visual Basic Programming
Kasun Ranga Wijeweera
 
PDF
CheckBoxes and RadioButtons
Kasun Ranga Wijeweera
 
PDF
Variables in Visual Basic Programming
Kasun Ranga Wijeweera
 
PDF
Loops in Visual Basic Programming
Kasun Ranga Wijeweera
 
PDF
Conditional Logic in Visual Basic Programming
Kasun Ranga Wijeweera
 
PDF
Assignment for Variables
Kasun Ranga Wijeweera
 
PDF
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Kasun Ranga Wijeweera
 
PDF
Assignment for Events
Kasun Ranga Wijeweera
 
PDF
Mastering Arrays Assignment
Kasun Ranga Wijeweera
 
Decorator Design Pattern in C#
Kasun Ranga Wijeweera
 
Singleton Design Pattern in C#
Kasun Ranga Wijeweera
 
Introduction to Design Patterns
Kasun Ranga Wijeweera
 
Algorithms for Convex Partitioning of a Polygon
Kasun Ranga Wijeweera
 
Geometric Transformations II
Kasun Ranga Wijeweera
 
Geometric Transformations I
Kasun Ranga Wijeweera
 
Introduction to Polygons
Kasun Ranga Wijeweera
 
Bresenham Line Drawing Algorithm
Kasun Ranga Wijeweera
 
Digital Differential Analyzer Line Drawing Algorithm
Kasun Ranga Wijeweera
 
Loops in Visual Basic: Exercises
Kasun Ranga Wijeweera
 
Conditional Logic: Exercises
Kasun Ranga Wijeweera
 
Getting Started with Visual Basic Programming
Kasun Ranga Wijeweera
 
CheckBoxes and RadioButtons
Kasun Ranga Wijeweera
 
Variables in Visual Basic Programming
Kasun Ranga Wijeweera
 
Loops in Visual Basic Programming
Kasun Ranga Wijeweera
 
Conditional Logic in Visual Basic Programming
Kasun Ranga Wijeweera
 
Assignment for Variables
Kasun Ranga Wijeweera
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Kasun Ranga Wijeweera
 
Assignment for Events
Kasun Ranga Wijeweera
 
Mastering Arrays Assignment
Kasun Ranga Wijeweera
 

Recently uploaded (20)

PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PDF
Immersive experiences: what Pharo users do!
ESUG
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
Presentation about variables and constant.pptx
safalsingh810
 
Immersive experiences: what Pharo users do!
ESUG
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Activate_Methodology_Summary presentatio
annapureddyn
 

Flood Filling Algorithm in C