mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-14 04:10:31 +02:00
Automated Merge Preparation
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
#include "Layer/PaintingArea.h"
|
||||
|
||||
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
|
||||
this->Area=Area;
|
||||
this->colorPicker=colorPicker;
|
||||
this->Toolsettings=Toolsettings;
|
||||
this->Area = Area;
|
||||
this->colorPicker = colorPicker;
|
||||
this->Toolsettings = Toolsettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ IntelliTool::~IntelliTool(){
|
||||
|
||||
void IntelliTool::onMouseRightPressed(int x, int y){
|
||||
if(isDrawing) {
|
||||
isDrawing=false;
|
||||
isDrawing = false;
|
||||
this->deleteToolLayer();
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ void IntelliTool::onMouseRightReleased(int x, int y){
|
||||
}
|
||||
|
||||
void IntelliTool::onMouseLeftPressed(int x, int y){
|
||||
this->isDrawing=this->createToolLayer();
|
||||
this->isDrawing = this->createToolLayer();
|
||||
if(isDrawing) {
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
@@ -32,7 +32,7 @@ void IntelliTool::onMouseLeftPressed(int x, int y){
|
||||
|
||||
void IntelliTool::onMouseLeftReleased(int x, int y){
|
||||
if(isDrawing) {
|
||||
isDrawing=false;
|
||||
isDrawing = false;
|
||||
this->mergeToolLayer();
|
||||
this->deleteToolLayer();
|
||||
activeLayer->image->calculateVisiblity();
|
||||
@@ -51,8 +51,8 @@ void IntelliTool::onWheelScrolled(int value){
|
||||
|
||||
bool IntelliTool::createToolLayer(){
|
||||
if(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)];
|
||||
this->activeLayer = &Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer)];
|
||||
this->Canvas = &Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer + 1)];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -63,15 +63,15 @@ void IntelliTool::mergeToolLayer(){
|
||||
QColor clr_1;
|
||||
QImage updatedImage = activeLayer->image->getImageData();
|
||||
|
||||
for(int y=0; y<activeLayer->height; y++) {
|
||||
for(int x=0; x<activeLayer->width; x++) {
|
||||
clr_0=updatedImage.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);
|
||||
int g =static_cast<int>(static_cast<float>(clr_1.green())*(t)+static_cast<float>(clr_0.green())*(1.f-t)+0.5f);
|
||||
int b =static_cast<int>(static_cast<float>(clr_1.blue())*(t)+static_cast<float>(clr_0.blue()*(1.f-t))+0.5f);
|
||||
int a =std::min(clr_0.alpha()+clr_1.alpha(), 255);
|
||||
for(int y = 0; y<activeLayer->height; y++) {
|
||||
for(int x = 0; x<activeLayer->width; x++) {
|
||||
clr_0 = updatedImage.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);
|
||||
int g = static_cast<int>(static_cast<float>(clr_1.green()) * (t) + static_cast<float>(clr_0.green()) * (1.f - t) + 0.5f);
|
||||
int b = static_cast<int>(static_cast<float>(clr_1.blue()) * (t) + static_cast<float>(clr_0.blue() * (1.f - t)) + 0.5f);
|
||||
int a = std::min(clr_0.alpha() + clr_1.alpha(), 255);
|
||||
clr_0.setRed(r);
|
||||
clr_0.setGreen(g);
|
||||
clr_0.setBlue(b);
|
||||
@@ -88,8 +88,8 @@ void IntelliTool::mergeToolLayer(){
|
||||
}
|
||||
|
||||
void IntelliTool::deleteToolLayer(){
|
||||
Area->deleteLayer(Area->activeLayer+1, true);
|
||||
this->Canvas=nullptr;
|
||||
Area->deleteLayer(Area->activeLayer + 1, true);
|
||||
this->Canvas = nullptr;
|
||||
}
|
||||
|
||||
IntelliTool::Tooltype IntelliTool::getTooltype(){
|
||||
|
||||
@@ -16,31 +16,31 @@ void IntelliToolCircle::drawCircle(int radius){
|
||||
QColor inner = this->colorPicker->getSecondColor();
|
||||
inner.setAlpha(Toolsettings->getInnerAlpha());
|
||||
int yMin, yMax, xMin, xMax;
|
||||
yMin = centerPoint.y()-radius;
|
||||
yMax = centerPoint.y()+radius;
|
||||
yMin = centerPoint.y() - radius;
|
||||
yMax = centerPoint.y() + radius;
|
||||
// x = x0+-sqrt(r2-(y-y0)2)
|
||||
for(int i=yMin; i<=yMax; i++) {
|
||||
xMin = static_cast<int>(centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
|
||||
xMax = static_cast<int>(centerPoint.x()+sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
|
||||
for(int i = yMin; i<=yMax; i++) {
|
||||
xMin = static_cast<int>(centerPoint.x() - sqrt(pow(radius,2) - pow(i - centerPoint.y(),2)));
|
||||
xMax = static_cast<int>(centerPoint.x() + sqrt(pow(radius,2) - pow(i - centerPoint.y(),2)));
|
||||
this->Canvas->image->drawLine(QPoint(xMin,i), QPoint(xMax,i),inner,1);
|
||||
}
|
||||
|
||||
//TODO implement circle drawing algorithm bresenham
|
||||
radius = static_cast<int>(radius +(Toolsettings->getLineWidth()/2.));
|
||||
yMin = (centerPoint.y()-radius);
|
||||
yMax = (centerPoint.y()+radius);
|
||||
for(int i=yMin; i<=yMax; i++) {
|
||||
xMin = static_cast<int>(centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
|
||||
xMax = static_cast<int>(centerPoint.x()+sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
|
||||
radius = static_cast<int>(radius + (Toolsettings->getLineWidth() / 2.));
|
||||
yMin = (centerPoint.y() - radius);
|
||||
yMax = (centerPoint.y() + radius);
|
||||
for(int i = yMin; i<=yMax; i++) {
|
||||
xMin = static_cast<int>(centerPoint.x() - sqrt(pow(radius,2) - pow(i - centerPoint.y(),2)));
|
||||
xMax = static_cast<int>(centerPoint.x() + sqrt(pow(radius,2) - pow(i - centerPoint.y(),2)));
|
||||
this->Canvas->image->drawPoint(QPoint(xMin,i), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
|
||||
this->Canvas->image->drawPoint(QPoint(xMax,i), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
|
||||
}
|
||||
|
||||
xMin = (centerPoint.x()-radius);
|
||||
xMax = (centerPoint.x()+radius);
|
||||
for(int i=xMin; i<=xMax; i++) {
|
||||
int yMin = static_cast<int>(centerPoint.y()-sqrt(pow(radius,2)-pow(i-centerPoint.x(),2)));
|
||||
int yMax = static_cast<int>(centerPoint.y()+sqrt(pow(radius,2)-pow(i-centerPoint.x(),2)));
|
||||
xMin = (centerPoint.x() - radius);
|
||||
xMax = (centerPoint.x() + radius);
|
||||
for(int i = xMin; i<=xMax; i++) {
|
||||
int yMin = static_cast<int>(centerPoint.y() - sqrt(pow(radius,2) - pow(i - centerPoint.x(),2)));
|
||||
int yMax = static_cast<int>(centerPoint.y() + sqrt(pow(radius,2) - pow(i - centerPoint.x(),2)));
|
||||
this->Canvas->image->drawPoint(QPoint(i, yMin), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
|
||||
this->Canvas->image->drawPoint(QPoint(i, yMax), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
|
||||
}
|
||||
@@ -57,7 +57,7 @@ void IntelliToolCircle::onMouseRightReleased(int x, int y){
|
||||
void IntelliToolCircle::onMouseLeftPressed(int x, int y){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
if(this->isDrawing) {
|
||||
this->centerPoint=QPoint(x,y);
|
||||
this->centerPoint = QPoint(x,y);
|
||||
int radius = 1;
|
||||
drawCircle(radius);
|
||||
Canvas->image->calculateVisiblity();
|
||||
@@ -70,14 +70,14 @@ void IntelliToolCircle::onMouseLeftReleased(int x, int y){
|
||||
|
||||
void IntelliToolCircle::onWheelScrolled(int value){
|
||||
IntelliTool::onWheelScrolled(value);
|
||||
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
|
||||
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
|
||||
}
|
||||
|
||||
void IntelliToolCircle::onMouseMoved(int x, int y){
|
||||
if(this->isDrawing) {
|
||||
this->Canvas->image->drawPlain(Qt::transparent);
|
||||
QPoint next(x,y);
|
||||
int radius = static_cast<int>(sqrt(pow((centerPoint.x()-x),2)+pow((centerPoint.y()-y),2)));
|
||||
int radius = static_cast<int>(sqrt(pow((centerPoint.x() - x),2) + pow((centerPoint.y() - y),2)));
|
||||
drawCircle(radius);
|
||||
}
|
||||
IntelliTool::onMouseMoved(x,y);
|
||||
|
||||
@@ -41,10 +41,10 @@ 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);
|
||||
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);
|
||||
|
||||
@@ -22,7 +22,7 @@ void IntelliToolLine::onMouseRightReleased(int x, int y){
|
||||
|
||||
void IntelliToolLine::onMouseLeftPressed(int x, int y){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
this->lineStartingPoint=QPoint(x,y);
|
||||
this->lineStartingPoint = QPoint(x,y);
|
||||
this->Canvas->image->drawPoint(lineStartingPoint, colorPicker->getFirstColor(),Toolsettings->getLineWidth());
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
@@ -33,7 +33,7 @@ void IntelliToolLine::onMouseLeftReleased(int x, int y){
|
||||
|
||||
void IntelliToolLine::onWheelScrolled(int value){
|
||||
IntelliTool::onWheelScrolled(value);
|
||||
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
|
||||
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
|
||||
}
|
||||
|
||||
void IntelliToolLine::onMouseMoved(int x, int y){
|
||||
|
||||
@@ -23,7 +23,7 @@ void IntelliToolPen::onMouseRightReleased(int x, int y){
|
||||
|
||||
void IntelliToolPen::onMouseLeftPressed(int x, int y){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
this->previousPoint=QPoint(x,y);
|
||||
this->previousPoint = QPoint(x,y);
|
||||
this->Canvas->image->drawPoint(previousPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
@@ -36,12 +36,12 @@ void IntelliToolPen::onMouseMoved(int x, int y){
|
||||
if(this->isDrawing) {
|
||||
QPoint newPoint(x,y);
|
||||
this->Canvas->image->drawLine(this->previousPoint, newPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||
this->previousPoint=newPoint;
|
||||
this->previousPoint = newPoint;
|
||||
}
|
||||
IntelliTool::onMouseMoved(x,y);
|
||||
}
|
||||
|
||||
void IntelliToolPen::onWheelScrolled(int value){
|
||||
IntelliTool::onWheelScrolled(value);
|
||||
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
|
||||
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0; i<static_cast<int>(QPointList.size()); i++) {
|
||||
int next = static_cast<int>((i+static_cast<int>(1))%static_cast<int>(QPointList.size()));
|
||||
for(int i = 0; i<static_cast<int>(QPointList.size()); i++) {
|
||||
int next = static_cast<int>((i + static_cast<int>(1)) % static_cast<int>(QPointList.size()));
|
||||
this->Canvas->image->drawLine(QPointList[static_cast<unsigned long long>(i)], QPointList[static_cast<unsigned long long>(next)], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ void IntelliToolRectangle::drawRectangle(QPoint otherCorner){
|
||||
|
||||
QColor clr = colorPicker->getSecondColor();
|
||||
clr.setAlpha(Toolsettings->getInnerAlpha());
|
||||
for(int y=yMin; y<=yMax; y++) {
|
||||
for(int y = yMin; y<=yMax; y++) {
|
||||
this->Canvas->image->drawLine(QPoint(xMin,y), QPoint(xMax, y), clr, 1);
|
||||
}
|
||||
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||
@@ -39,7 +39,7 @@ void IntelliToolRectangle::onMouseRightReleased(int x, int y){
|
||||
|
||||
void IntelliToolRectangle::onMouseLeftPressed(int x, int y){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
this->originCorner=QPoint(x,y);
|
||||
this->originCorner = QPoint(x,y);
|
||||
drawRectangle(originCorner);
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
@@ -59,5 +59,5 @@ void IntelliToolRectangle::onMouseMoved(int x, int y){
|
||||
|
||||
void IntelliToolRectangle::onWheelScrolled(int value){
|
||||
IntelliTool::onWheelScrolled(value);
|
||||
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
|
||||
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user