2019-12-09 14:32:30 +01:00
|
|
|
//
|
|
|
|
// Created by shaohuatong on 06.12.19.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include "Shapes.hpp"
|
|
|
|
|
|
|
|
void Shapes::addShape(std::vector<std::vector<bool>> shape, int startX, int startY, int endX, int endY) {
|
|
|
|
count++;
|
|
|
|
|
|
|
|
shapes.resize(count);
|
|
|
|
startXs.resize(count);
|
|
|
|
startYs.resize(count);
|
|
|
|
endXs.resize(count);
|
|
|
|
endYs.resize(count);
|
|
|
|
|
|
|
|
startXs[count-1] = startX;
|
|
|
|
startYs[count-1] = startY;
|
|
|
|
endXs[count-1] = endX;
|
|
|
|
endYs[count-1] = endY;
|
|
|
|
|
2019-12-11 11:49:58 +01:00
|
|
|
// shapes[count-1].resize(shape.size());
|
|
|
|
// for(int y = 0; y < shape.size(); y++) {
|
|
|
|
// shapes[count-1][y].resize(shape[y].size());
|
|
|
|
// for(int x = 0; x < shape[y].size(); x++) {
|
|
|
|
// shapes[count-1][y][x] = shape[y][x];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
shapes[count-1] = shape;
|
2019-12-09 14:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Shapes::containsPixel(int x, int y) {
|
|
|
|
for(int i = 0; i < count; i++) {
|
2019-12-11 11:49:58 +01:00
|
|
|
if(x >= startXs[i] && x < endXs[i] && y >= startYs[i] && y < endYs[i]) {
|
2019-12-09 14:32:30 +01:00
|
|
|
if(shapes[i][y-startYs[i]][x-startXs[i]]) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Shapes::getCount() {
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::vector<bool>> Shapes::getShape(int index) {
|
|
|
|
return shapes[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
int Shapes::getStartX(int index) {
|
|
|
|
return startXs[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
int Shapes::getStartY(int index) {
|
|
|
|
return startYs[index];
|
|
|
|
}
|