This commit is contained in:
Fabien Freling 2022-02-17 23:15:45 +01:00
parent 4447cd67d1
commit 5b32c517c1
12 changed files with 179 additions and 16 deletions

34
src/mask.cpp Normal file
View 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