-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsampler.cpp
More file actions
35 lines (29 loc) · 730 Bytes
/
Copy pathsampler.cpp
File metadata and controls
35 lines (29 loc) · 730 Bytes
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
#include "sampler.h"
#include "color.h"
Sampler::Sampler() {
curx = 0.5f;
cury = 0.5f;
boundx = 0;
boundy = 0;
}
Sampler::Sampler(int x, int y) {
curx = 0.5f;
cury = 0.5f;
boundx = x;
boundy = y;
}
// get the next pixel in the screen
bool Sampler::getSample(Sample* sample) {
if(curx > boundx) { //end of line, go to the next line
cury = cury + 1.0f;
if(cury > boundy) { // out of bounds
return false;
}
curx = 0.5f; //set x back to beginning if the function didn't return false (new line case)
}
*sample = Sample(curx, cury); // new sample
//cout << "Sample: (" << sample->x << ", " << sample->y << ")";
//cout << "Cur: (" << curx << ", " << cury << ")" << endl;
curx = curx + 1.0f;
return true;
}