add mask
This commit is contained in:
parent
4447cd67d1
commit
5b32c517c1
12 changed files with 179 additions and 16 deletions
34
src/mask.cpp
Normal file
34
src/mask.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include "mask.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
namespace freling {
|
||||
|
||||
Mask::Mask(uint32_t width, uint32_t height) : width(width), height(height) {
|
||||
data.resize(width * height, true);
|
||||
}
|
||||
|
||||
void Mask::fill(bool value) {
|
||||
for (int i = 0, size = data.size(); i < size; ++i) {
|
||||
data[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void Mask::set(int x, int y, bool value) {
|
||||
assert(x < width);
|
||||
assert(y < height);
|
||||
|
||||
const int i = x + y * width;
|
||||
data[i] = value;
|
||||
}
|
||||
|
||||
bool Mask::get(int x, int y) {
|
||||
assert(x < width);
|
||||
assert(y < height);
|
||||
|
||||
const int i = x + y * width;
|
||||
return data[i];
|
||||
}
|
||||
|
||||
} // namespace freling
|
Loading…
Add table
Add a link
Reference in a new issue