Merge branch 'dev-variable-refractor' into dev

This commit is contained in:
2019-12-20 10:13:59 +01:00
23 changed files with 154 additions and 153 deletions

View File

@@ -12,8 +12,8 @@ IntelliTool::~IntelliTool(){
}
void IntelliTool::onMouseRightPressed(int x, int y){
if(drawing) {
drawing=false;
if(isDrawing) {
isDrawing=false;
this->deleteToolLayer();
}
}
@@ -23,23 +23,23 @@ void IntelliTool::onMouseRightReleased(int x, int y){
}
void IntelliTool::onMouseLeftPressed(int x, int y){
this->drawing=true;
this->isDrawing=true;
//create drawing layer
this->createToolLayer();
Canvas->image->calculateVisiblity();
}
void IntelliTool::onMouseLeftReleased(int x, int y){
if(drawing) {
drawing=false;
if(isDrawing) {
isDrawing=false;
this->mergeToolLayer();
this->deleteToolLayer();
Active->image->calculateVisiblity();
activeLayer->image->calculateVisiblity();
}
}
void IntelliTool::onMouseMoved(int x, int y){
if(drawing)
if(isDrawing)
Canvas->image->calculateVisiblity();
}
@@ -48,17 +48,17 @@ void IntelliTool::onWheelScrolled(int value){
}
void IntelliTool::createToolLayer(){
Area->createTempLayerAfter(Area->activeLayer);
this->Active=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer)];
this->Canvas=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer+1)];
Area->createTempTopLayer(Area->activeLayer);
this->activeLayer=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer)];
this->Canvas=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer+1)];
}
void IntelliTool::mergeToolLayer(){
QColor clr_0;
QColor clr_1;
for(int y=0; y<Active->height; y++) {
for(int x=0; x<Active->width; x++) {
clr_0=Active->image->imageData.pixelColor(x,y);
for(int y=0; y<activeLayer->height; y++) {
for(int x=0; x<activeLayer->width; x++) {
clr_0=activeLayer->image->imageData.pixelColor(x,y);
clr_1=Canvas->image->imageData.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha())/255.f;
int r =static_cast<int>(static_cast<float>(clr_1.red())*(t)+static_cast<float>(clr_0.red())*(1.f-t)+0.5f);
@@ -70,7 +70,7 @@ void IntelliTool::mergeToolLayer(){
clr_0.setBlue(b);
clr_0.setAlpha(a);
Active->image->imageData.setPixelColor(x, y, clr_0);
activeLayer->image->imageData.setPixelColor(x, y, clr_0);
}
}
}