-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestFills.cpp
237 lines (224 loc) · 7.46 KB
/
testFills.cpp
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#define CATCH_CONFIG_MAIN
#include "cs221util/catch.hpp"
#include <limits.h>
#include <vector>
#include <sys/stat.h>
#include <iostream>
#include "cs221util/PNG.h"
#include "cs221util/HSLAPixel.h"
#include "filler.h"
#include "stripeColorPicker.h"
#include "rainbowColorPicker.h"
#include "borderColorPicker.h"
#include "customColorPicker.h"
using namespace std;
using namespace cs221util;
#define FUNCTORTESTHEIGHT 60
#define FUNCTORTESTWIDTH 60
#define FUNCTORTESTFREQ 10
#define FUNCTORTESTX 40
#define FUNCTORTESTY 10
#define FUNCTORTESTRADIUS 45
#define FUNCTORTESTGRIDSPACING 8
// use the following for border tests
#define SOLIDX 80
#define SOLIDY 80
#define SOLIDTOLERANCE 0.01
#define SOLIDTESTIMAGE "originals/Canada.png"
#define SOLIDFRAMEFREQ 100
#define CUSTOMTESTIMAGE "originals/n.png"
// use the following for stripe tests
#define GRIDX 120
#define GRIDY 75
#define GRIDTOLERANCE 0.008
#define GRIDTESTIMAGE "originals/mooncake.png"
#define GRIDFRAMEFREQ 50
#define GRIDGRIDSPACING 5
// use for rainbow
#define RAINFREQ 1.0/1000.0
#define RAINTOLERANCE 0.05
#define RAINX 75
#define RAINY 75
#define RAINTESTIMAGE "originals/cloud.png"
#define RAINFRAMEFREQ 500
PNG testColorPicker(colorPicker& picker)
{
PNG img;
img.resize(FUNCTORTESTWIDTH, FUNCTORTESTHEIGHT);
HSLAPixel px;
for (int x = 1; x < FUNCTORTESTWIDTH; x = x + x) {
for (int y = 1; y < FUNCTORTESTHEIGHT; y = y + y) {
px = picker(x, y);
// these create the output useful for debugging fills
cout << "\toperator()(" << x << ", " << y << ") = {"
<< (int)px.h << ", "
<< (int)px.s << ", "
<< (int)px.l << "}" << endl;
}
}
for (int x = 0; x < FUNCTORTESTWIDTH; x++){
for (int y = 0; y < FUNCTORTESTHEIGHT; y++){
HSLAPixel * p = img.getPixel(x,y);
* p = picker(x, y);
}
}
return img;
}
//
// TEST_CASE("colorPicker::basic stripe","[weight=1][part=colorPicker]"){
// HSLAPixel px1;
// px1.h = 120;
// px1.s = 1.0; px1.l = 0.25;
// stripeColorPicker stripePicker(px1, FUNCTORTESTGRIDSPACING);
//
// PNG result = testColorPicker(stripePicker);
// result.writeToFile("images/stripeColorPickerTest.png");
// PNG expected; expected.readFromFile("soln_images/stripeColorPickerTest.png");
// REQUIRE(result == expected);
// }
//
// TEST_CASE("colorPicker::basic rainbow","[weight=1][part=colorPicker]"){
// rainbowColorPicker rainPicker(1.0/1000.0);
//
// PNG result = testColorPicker(rainPicker);
// result.writeToFile("images/rainColorPickerTest.png");
// PNG expected; expected.readFromFile("soln_images/rainColorPickerTest.png");
// REQUIRE(result == expected);
//
// }
//
// TEST_CASE("colorPicker::basic border","[weight=1][part=colorPicker]"){
//
// PNG img;
// img.resize(FUNCTORTESTWIDTH, FUNCTORTESTHEIGHT);
//
// HSLAPixel px1;
// px1.h = 360.;
// px1.s = 1.0; px1.l = 0.5;
// HSLAPixel px2;
//
// borderColorPicker borderPicker(px1, img, 0.4, px2);
//
// PNG result = testColorPicker(borderPicker);
// result.writeToFile("images/borderColorPickerTest.png");
// PNG expected; expected.readFromFile("soln_images/borderColorPickerTest.png");
// REQUIRE(result == expected);
// }
// TEST_CASE("colorPicker::basic custom","[weight=1][part=colorPicker]"){
//
// PNG img;
// img.resize(FUNCTORTESTWIDTH, FUNCTORTESTHEIGHT);
//
// customColorPicker customPicker(img);
//
// PNG result = testColorPicker(customPicker);
// result.writeToFile("images/customColorPickerTest.png");
// // PNG expected; expected.readFromFile("soln_images/borderColorPickerTest.png");
// REQUIRE(1 == 1);
// }
// TEST_CASE("fill::basic custom dfs","[weight=1][part=fill]"){
// PNG img;
// img.readFromFile(CUSTOMTESTIMAGE);
//
// animation anim;
// anim = filler::fillCustomDFS(img, SOLIDX, SOLIDY, 1, 750);
// PNG result = anim.write("images/dfscustom.gif");
// result.writeToFile("images/dfscustom.png");
//
// REQUIRE(1==1);
// }
//
TEST_CASE("fill::basic custom bfs","[weight=1][part=fill]"){
PNG img;
img.readFromFile(CUSTOMTESTIMAGE);
animation anim;
anim = filler::fillCustomBFS(img, SOLIDX, SOLIDY, 1, 10000);
PNG result = anim.write("images/bfscustom.gif");
result.writeToFile("images/bfscustom.png");
REQUIRE(1==1);
}
//
// TEST_CASE("fill::basic border dfs","[weight=1][part=fill]"){
// PNG img;
// img.readFromFile(SOLIDTESTIMAGE);
// HSLAPixel px(200., 1.0, 0.5);
//
// animation anim;
// anim = filler::fillBorderDFS(img, SOLIDX, SOLIDY, px, SOLIDTOLERANCE, SOLIDFRAMEFREQ);
// PNG result = anim.write("images/dfsborder.gif");
// result.writeToFile("images/dfsborder.png");
// PNG expected; expected.readFromFile("soln_images/dfsborder.png");
// REQUIRE(result==expected);
// }
//
// TEST_CASE("fill::basic border bfs","[weight=1][part=fill]"){
// PNG img;
// img.readFromFile(SOLIDTESTIMAGE);
// HSLAPixel px(200., 1.0, 0.5);
//
// animation anim;
// anim = filler::fillBorderBFS(img, SOLIDX, SOLIDY, px, SOLIDTOLERANCE, SOLIDFRAMEFREQ);
// PNG result = anim.write("images/bfsborder.gif");
// result.writeToFile("images/bfsborder.png");
// PNG expected; expected.readFromFile("soln_images/bfsborder.png");
// REQUIRE(result==expected);
// }
//
// TEST_CASE("fill::basic stripe dfs","[weight=1][part=fill]"){
// PNG img;
// img.readFromFile(GRIDTESTIMAGE);
// HSLAPixel px(40., 1.0, 0.5);
//
// animation anim;
// anim = filler::fillStripeDFS(img, GRIDX, GRIDY, px, GRIDGRIDSPACING,
// GRIDTOLERANCE, GRIDFRAMEFREQ);
// PNG result = anim.write("images/dfsstripe.gif");
// result.writeToFile("images/dfsstripe.png");
// PNG expected; expected.readFromFile("soln_images/dfsstripe.png");
// REQUIRE(result==expected);
// }
//
// TEST_CASE("fill::basic stripe bfs","[weight=1][part=fill]"){
// PNG img;
// img.readFromFile(GRIDTESTIMAGE);
// HSLAPixel px(200., 1.0, 0.5);
//
// animation anim;
// anim = filler::fillStripeBFS(img, GRIDX, GRIDY, px, GRIDGRIDSPACING,
// GRIDTOLERANCE, GRIDFRAMEFREQ);
// PNG result = anim.write("images/bfsstripe.gif");
// result.writeToFile("images/bfsstripe.png");
// PNG expected; expected.readFromFile("soln_images/bfsstripe.png");
// REQUIRE(result==expected);
// } //
//
// TEST_CASE("fill::basic rainbow dfs","[weight=1][part=fill]"){
//
// PNG img;
// img.readFromFile(RAINTESTIMAGE);
//
// animation anim;
// anim = filler::fillRainDFS(img, RAINX, RAINY, RAINFREQ,
// RAINTOLERANCE,
// RAINFRAMEFREQ);
// PNG result = anim.write("images/dfsrain.gif");
// result.writeToFile("images/dfsrain.png");
// PNG expected; expected.readFromFile("soln_images/dfsrain.png");
// REQUIRE(result==expected);
//
// }
// TEST_CASE("fill::basic rainbow bfs","[weight=1][part=fill]"){
//
// PNG img;
// img.readFromFile(RAINTESTIMAGE);
//
// animation anim;
// anim = filler::fillRainBFS(img, RAINX, RAINY, RAINFREQ,
// RAINTOLERANCE,
// RAINFRAMEFREQ);
// PNG result = anim.write("images/bfsrain.gif");
// result.writeToFile("images/bfsrain.png");
// PNG expected; expected.readFromFile("soln_images/bfsrain.png");
// REQUIRE(result==expected);
//
// }