0% found this document useful (0 votes)
25 views

Floodfill algorithm

Uploaded by

estiaksazid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Floodfill algorithm

Uploaded by

estiaksazid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Chittagong University of Engineering and Technology

Department Of Computer Science and Engineering


Lab Report
Course No. : CSE-458
Course Title : Computer Graphics (Sessional)
Experiment No : 06
Experiment Name : Implementation of Flood Fill Algorithm
Date of Submission : 22/06/2023

Submitted To:
Shuhena Salam Aonty
Lecturer,
Department of CSE, CUET

Submitted By: Remarks


Name : Estiak Ahamed Sazid
ID : 1804051
Section :A
Level :4
Term :1
Source Code
#include<windows.h> {
#include<GL/glu.h> setPixel(x, y, fillColor);
#include<GL/glut.h> floodFill(x + 1, y, fillColor,
#include<stdio.h> interiorColor);
#include<stdlib.h> floodFill(x - 1, y, fillColor,
void setPixel(int x, int y, float color[]) interiorColor);
{ floodFill(x, y + 1, fillColor,
glColor3fv(color); interiorColor);
glBegin(GL_POINTS); floodFill(x, y - 1, fillColor,
glVertex2i(x, y); interiorColor);
glEnd(); floodFill(x+1, y+1, fillColor,
glFlush(); interiorColor);
} floodFill(x-1, y+1, fillColor,
void getPixel(int x, int y, float color[]) interiorColor);
{ floodFill(x+1, y-1, fillColor,
glReadPixels(x, y, 1, 1, GL_RGB, interiorColor);
GL_FLOAT, color); floodFill(x-1, y-1, fillColor,
} interiorColor);
void floodFill(int x, int y, float fillColor[], }
float interiorColor[]) }
{ void display()
float currentColor[3]; {
getPixel(x, y, currentColor); glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
if ((currentColor[0] != interiorColor[0] ||
currentColor[1] != interiorColor[1] || glColor3f(0.0, 0.0, 0.0);
currentColor[2] != interiorColor[2]) && glLineWidth(2.0);
(currentColor[0] != fillColor[0] || glBegin(GL_LINE_LOOP);
currentColor[1] != fillColor[1] || glVertex2i(50, 50);
currentColor[2] != fillColor[2])) glVertex2i(200, 50);
glVertex2i(200, 200);
glVertex2i(50, 200);
glEnd();
glFlush();
float fillColor[] = {0.0, 0.0, 1.0};
float interiorColor[] = {0.0, 0.0, 0.0};
int x = 70;
int y = 70;
floodFill(x, y, fillColor, interiorColor);
}
void init()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 500.0, 0.0, 500.0);
glMatrixMode(GL_MODELVIEW);
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE |
GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow("Flood Fill
Algorithm");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Output

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy