Skip to main content

Write A Program To Fill A Circle Using Flood Fill Algorithm | VCMIT

Fill A Circle Using Flood Fill Algorithm


INPUT

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void floodFill(int, int, int, int);
int midx=319, midy=239;
void main()
{
int gdriver=DETECT, gmode, x,y,r;
initgraph(&gdriver, &gmode, "C:\\TURBOCS3\\BGI");
cleardevice();
printf("Enter the Center of circle (X,Y) : ");
scanf("%d %d",&x,&y);
printf("Enter the Radius of circle R : ");
scanf("%d",&r);
circle(midx+x,midy-y,r);
getch();
floodFill(midx+x,midy-y,13,0);
getch();
closegraph();
}

void floodFill(int x, int y, int fill, int old)
{
if(getpixel(x,y) == old)
{
putpixel(x,y,fill);
delay(5);
floodFill(x+1,y,fill,old);
floodFill(x-1,y,fill,old);
floodFill(x,y+1,fill,old);
floodFill(x,y-1,fill,old);
}
}

OUTPUT


Comments

Popular posts from this blog

Create House Like Structure Perform Operations Program In C | VCMIT

Program to create a house like figure and perform the following operations.  Scaling about the origin followed by translation.  Scaling with reference to an arbitrary point. Reflect about the line y = mx + c. INPUT #include <stdio.h> #include <graphics.h> #include <stdlib.h> #include <math.h> #include <conio.h> void reset (int h[][2]) { int val[9][2] = { { 50, 50 },{ 75, 50 },{ 75, 75 },{ 100, 75 }, { 100, 50 },{ 125, 50 },{ 125, 100 },{ 87, 125 },{ 50, 100 } }; int i; for (i=0; i<9; i++) { h[i][0] = val[i][0]-50; h[i][1] = val[i][1]-50; } } void draw (int h[][2]) { int i; setlinestyle (DOTTED_LINE, 0, 1); line (320, 0, 320, 480); line (0, 240, 640, 240); setlinestyle (SOLID_LINE, 0, 1); for (i=0; i<8; i++) line (320+h[i][0], 240-h[i][1], 320+h[i+1][0], 240-h[i+1][1]); line (320+h[0][0], 240-h[0][1], 320+h[8][0], 240-h[8][1]); } void rotate (int h[][2], float angle) { int i; for (i=0; i<9; i++) { int xnew, ynew; xnew = h[i][0] * cos (angl...

Software Engineering - Waterfall Model | VCMIT

Waterfall model Winston Royce introduced the Waterfall Model in 1970.This model has five phases: Requirements analysis and specification, design, implementation, and unit testing, integration and system testing, and operation and maintenance. The steps always follow in this order and do not overlap. The developer must complete every phase before the next phase begins. This model is named "Waterfall Model", because its diagrammatic representation resembles a cascade of waterfalls. 1. Requirements analysis and specification phase: The aim of this phase is to understand the exact requirements of the customer and to document them properly. Both the customer and the software developer work together so as to document all the functions, performance, and interfacing requirement of the software. It describes the "what" of the system to be produced and not "how."In this phase, a large document called Software Requirement Specification (SRS) document is created whic...

Software Engineering - Spiral Model | VCMIT

Spiral Model The spiral model, initially proposed by Boehm, is an evolutionary software process model that couples the iterative feature of prototyping with the controlled and systematic aspects of the linear sequential model. It implements the potential for rapid development of new versions of the software. Using the spiral model, the software is developed in a series of incremental releases. During the early iterations, the additional release may be a paper model or prototype. During later iterations, more and more complete versions of the engineered system are produced. Each cycle in the spiral is divided into four parts: Objective setting: Each cycle in the spiral starts with the identification of purpose for that cycle, the various alternatives that are possible for achieving the targets, and the constraints that exists. Risk Assessment and reduction: The next phase in the cycle is to calculate these various alternatives based on the goals and constraints. The focus of evaluation ...