the flood fill algorithm l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
The “Flood Fill” Algorithm PowerPoint Presentation
Download Presentation
The “Flood Fill” Algorithm

Loading in 2 Seconds...

play fullscreen
1 / 8

The “Flood Fill” Algorithm - PowerPoint PPT Presentation


  • 508 Views
  • Uploaded on

The “Flood Fill” Algorithm. A recursive graphics algorithm used to fill in irregular-shaped regions with a solid color . Region Boundaries. We often want to “color” regions which are defined by an irregular-shaped boundary

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'The “Flood Fill” Algorithm' - bernad


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
the flood fill algorithm

The “Flood Fill” Algorithm

A recursive graphics algorithm used to fill in irregular-shaped regions with a solid color

region boundaries
Region Boundaries
  • We often want to “color” regions which are defined by an irregular-shaped boundary
  • Our earlier “scanline-fill” algorithm worked well for regions with boundaries defined by straight line-segments, or by circular arcs
  • But more complicated regions could lead to programming difficulties if the scanline approach is taken
alternative simple recursion
Alternative: simple recursion
  • A “recursive” approach may be simpler
  • It works by successively reducing a very complicated problem to one that is just a little bit easier to solve
  • We apply that idea to a graphics problem: coloring the interior of an irregular region
a flood fill algorithm
A flood-fill algorithm

void fill( int x, int y, int interiorcolor, int newcolor )

{

if ( get_pixel( x, y ) == interiorcolor )

{

put_pixel( x, y, newcolor );

fill( x -1, y, interiorcolor, newcolor );

fill( x+1, y, interiorcolor, newcolor );

fill( x, y -1, interiorcolor, newcolor );

fill( x, y+1, interiorcolor, newcolor );

}

}

demonstration setup
Demonstration setup
  • We need a way to create irregular regions
  • We will do it by using “bezier curves”
  • We subdivide the viewpoint into quadrants
  • We form a bezier curve in each quadrant
  • These bezier curves will connect together
  • First and last control-points are mid-axes
  • Other control-points are randomly chosen
demo program
Demo-program
  • Our ‘flood.cpp’ demo implements this idea
  • You can find it on our course website
  • It does all of its drawing on page 0
  • But you might want to draw to page 1, and then afterward copy from page 1 to page 0
  • That avoids your user seeing the effects of a “slow” drawing operation in-progress