mp_traversals
Terrible Traversals
FloodFilledImage Class Reference

This class is used to do flood fill on an image. More...

#include <FloodFilledImage.h>

Public Member Functions

 FloodFilledImage (const PNG &png)
 Constructs a new instance of a FloodFilledImage with a image png. More...
 
void addFloodFill (Traversals::ImageTraversal &traversal, ColorPicker &colorPicker)
 Adds a FloodFill operation to the FloodFillImage. More...
 
Animation animate (unsigned frameInterval) const
 Creates an Animation of frames from the FloodFill operations added to this object. More...
 

Detailed Description

This class is used to do flood fill on an image.

One or more FloodFill operations will be added and executed in the order they are added in. Each operation should flood-fill the entire image. Each operation should have its own traversal method and color picker.

Constructor & Destructor Documentation

◆ FloodFilledImage()

FloodFilledImage::FloodFilledImage ( const PNG png)

Constructs a new instance of a FloodFilledImage with a image png.

Parameters
pngThe starting image of a FloodFilledImage
Todo:
[Part 2]

Member Function Documentation

◆ addFloodFill()

void FloodFilledImage::addFloodFill ( Traversals::ImageTraversal traversal,
ColorPicker colorPicker 
)

Adds a FloodFill operation to the FloodFillImage.

This function must store the operation, which will be used by animate.

Parameters
traversalImageTraversal used for this FloodFill operation.
colorPickerColorPicker used for this FloodFill operation.
Todo:
[Part 2]

◆ animate()

Animation FloodFilledImage::animate ( unsigned  frameInterval) const

Creates an Animation of frames from the FloodFill operations added to this object.

Each FloodFill operation added by addFloodFill is executed based on the order the operation was added. This is done by:

  1. Visiting pixels within the image based on the order provided by the ImageTraversal iterator and
  2. Updating each pixel to a new color based on the ColorPicker

While applying the FloodFill to the image, an Animation is created by saving the image after every frameInterval pixels are filled. To ensure a smooth Animation, the first frame is always the starting image and the final frame is always the finished image.

(For example, if frameInterval is 4 the frames are:

  • The initial frame
  • Then after the 4th pixel has been filled
  • Then after the 8th pixel has been filled
  • ...
  • The final frame, after all pixels have been filed)
    Parameters
    frameIntervalhow often to save frames of the animation
Todo:
[Part 2]

The documentation for this class was generated from the following files: