Merge branch 'dev' into UnitTesting

This commit is contained in:
2020-01-16 11:24:44 +01:00
38 changed files with 1179 additions and 383 deletions

View File

@@ -25,7 +25,7 @@ void IntelliToolFloodFill::onMouseRightReleased(int x, int y){
void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
if(!(x>=0 && x<Area->getWidthOfActive() && y>=0 && y<Area->getHeightOfActive())) {
return;
}
}
IntelliTool::onMouseLeftPressed(x,y);
QPoint start(x,y);
@@ -33,10 +33,10 @@ void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
Q.push(start);
QColor oldColor = this->activeLayer->image->getPixelColor(start);
QColor newColor = this->colorPicker->getFirstColor();
if(newColor == oldColor){
return;
}
QColor newColor = this->colorPicker->getFirstColor();
if(newColor == oldColor) {
return;
}
Canvas->image->drawPixel(start,newColor);
QPoint left, right, top, down;
@@ -44,24 +44,24 @@ void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
QPoint Current = Q.front();
Q.pop();
left = QPoint(Current.x()-1,Current.y() );
right = QPoint(Current.x()+1,Current.y() );
top = QPoint(Current.x(),Current.y()-1);
down = QPoint(Current.x(),Current.y()+1);
if((right.x() < Canvas->width) && (Canvas->image->getPixelColor(right) != newColor) && (activeLayer->image->getPixelColor(right) == oldColor)) {
left = QPoint(Current.x() - 1,Current.y() );
right = QPoint(Current.x() + 1,Current.y() );
top = QPoint(Current.x(),Current.y() - 1);
down = QPoint(Current.x(),Current.y() + 1);
if((right.x() < Canvas->width) && (Canvas->image->getPixelColor(right) != newColor) && (activeLayer->image->getPixelColor(right) == oldColor)) {
Canvas->image->drawPixel(right,newColor);
Q.push(right);
}
if((left.x() >= 0) && (Canvas->image->getPixelColor(left) != newColor) && (activeLayer->image->getPixelColor(left) == oldColor)) {
if((left.x() >= 0) && (Canvas->image->getPixelColor(left) != newColor) && (activeLayer->image->getPixelColor(left) == oldColor)) {
Canvas->image->drawPixel(left,newColor);
Q.push(left);
}
if((top.y() >= 0) && (Canvas->image->getPixelColor(top) != newColor) && (activeLayer->image->getPixelColor(top) == oldColor)) {
if((top.y() >= 0) && (Canvas->image->getPixelColor(top) != newColor) && (activeLayer->image->getPixelColor(top) == oldColor)) {
Canvas->image->drawPixel(top,newColor);
Q.push(top);
}
if((down.y() < Canvas->height) && (Canvas->image->getPixelColor(down) != newColor) && (activeLayer->image->getPixelColor(down) == oldColor)) {
Canvas->image->drawPixel(down,newColor);
if((down.y() < Canvas->height) && (Canvas->image->getPixelColor(down) != newColor) && (activeLayer->image->getPixelColor(down) == oldColor)) {
Canvas->image->drawPixel(down,newColor);
Q.push(down);
}
}