-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiller.h
149 lines (134 loc) · 6.43 KB
/
filler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/**
* @file filler.h
* Defintion of a filler namespace.
*
*/
#ifndef _FILLER_H_
#define _FILLER_H_
#include "cs221util/PNG.h"
#include "stack.h"
#include "queue.h"
#include "cs221util/HSLAPixel.h"
#include "animation.h"
#include "rainbowColorPicker.h" // given as an example
#include "borderColorPicker.h"
#include "stripeColorPicker.h"
#include "customColorPicker.h"
using namespace cs221util;
/**
* filler namespace: specifies a set of functions for performing flood
* fills on images.
*
*/
namespace filler
{
/**
* Performs a flood fill on the given image using a stripe,
* employing a depth-first-search approach.
*
* @param img The image to be filled.
* @param x The starting x coordinate for the fill.
* @param y The starting y coordinate for the fill.
* @param fillColor The color the stripes should appear.
* @param stripeSpacing The width of the stripe spacing.
* @param tolerance How different colors are allowed to be to still be
* included in the fill.
* @param frameFreq How frequently to add a frame to the animation, in
* pixels. For instance, if frameFreq == 1, a frame is added when every
* pixel is filled. If frameFreq == 10, a frame is added after every 10
* pixels is filled.
* @return An animation that shows the fill progressing over the image.
*/
animation fillStripeDFS(PNG& img, int x, int y, HSLAPixel fillColor,
int stripeSpacing, double tolerance, int frameFreq);
/**
* Performs a flood fill on the given image but only colors the
* border of the fill region. Employs a depth-first-search approach.
*
* @param img The image to be filled.
* @param x The starting x coordinate for the fill.
* @param y The starting y coordinate for the fill.
* @param fillColor The color the border should appear.
* @param tolerance How far away colors are allowed to be to still be
* included in the fill.
* @param frameFreq How frequently to add a frame to the animation, in
* pixels. For instance, if frameFreq == 1, a frame is added when every
* pixel is filled. If frameFreq == 10, a frame is added after every 10
* pixels is filled.
* @return An animation that shows the fill progressing over the image.
*/
animation fillBorderDFS(PNG& img, int x, int y, HSLAPixel borderColor,
double tolerance, int frameFreq);
animation fillCustomDFS(PNG& img, int x, int y,
double tolerance, int frameFreq);
animation fillCustomBFS(PNG& img, int x, int y,
double tolerance, int frameFreq);
/**
* Performs a flood fill on the given image using a stripe,
* employing a breadth-first-search approach.
*
* @param img The image to be filled.
* @param x The starting x coordinate for the fill.
* @param y The starting y coordinate for the fill.
* @param fillColor The color the stripes should appear.
* @param stripeSpacing The width of the stripe spacing.
* @param tolerance How different colors are allowed to be to still be
* included in the fill.
* @param frameFreq How frequently to add a frame to the animation, in
* pixels. For instance, if frameFreq == 1, a frame is added when every
* pixel is filled. If frameFreq == 10, a frame is added after every 10
* pixels is filled.
* @return An animation that shows the fill progressing over the image.
*/
animation fillStripeBFS(PNG& img, int x, int y, HSLAPixel fillColor,
int stripeSpacing, double tolerance, int frameFreq);
/**
* Performs a flood fill on the given image but only colors the
* border of the fill region. Employs a breadth-first-search approach.
*
* @param img The image to be filled.
* @param x The starting x coordinate for the fill.
* @param y The starting y coordinate for the fill.
* @param fillColor The color the border should appear.
* @param tolerance How far away colors are allowed to be to still be
* included in the fill.
* @param frameFreq How frequently to add a frame to the animation, in
* pixels. For instance, if frameFreq == 1, a frame is added when every
* pixel is filled. If frameFreq == 10, a frame is added after every 10
* pixels is filled.
* @return An animation that shows the fill progressing over the image.
*/
animation fillBorderBFS(PNG& img, int x, int y, HSLAPixel borderColor,
double tolerance, int frameFreq);
/* The following two functions are given to you as examples of
* working fill functions.
*/
animation fillRainDFS(PNG& img, int x, int y,
long double freq, double tolerance, int frameFreq);
animation fillRainBFS(PNG& img, int x, int y,
long double freq, double tolerance, int frameFreq);
/**
* Filling function: a general helper that should be invoked by
* ALL of the public fill functions parameterized by the appropriate
* color picker for that type of fill.
*
* @param img Image to do the filling on.
* @param x X coordinate to start the fill from.
* @param y Y coordinate to start the fill from.
* @param fillColor The colorPicker function object to be used for the fill.
* @param tolerance How different colors are allowed to be to still be
* included in the fill.
* @param frameFreq How frequently to add a frame to the animation, in
* pixels. For instance, if frameFreq == 1, a frame is added when every
* pixel is filled. If frameFreq == 10, a frame is added after every 10
* pixels is filled.
* @return An animation that shows the fill progressing over the image.
*/
template <template <class T> class OrderingStructure>
animation fill(PNG& img, int x, int y, colorPicker& fillColor,
double tolerance, int frameFreq);
void processPixel(PNG& img, int x, int y, colorPicker& fillColor,
double tolerance, animation& anim, int frameFreq, OrderingStructure<pair<int,int>>& os);
}
#include "filler.cpp"
#endif