mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-15 21:00:37 +02:00
Gradient Fertig
This commit is contained in:
@@ -1 +1,3 @@
|
|||||||
history tool doesnt load polygon data on undo iff project was loaded
|
history tool doesnt load polygon data on undo iff project was loaded
|
||||||
|
history tool doesnt save delete Layer
|
||||||
|
Gradient breaks Heap Size, when big Witdh and Height (appeared on 1280x720)
|
||||||
@@ -21,7 +21,6 @@ void IntelliToolGradient::onMouseLeftPressed(int x, int y){
|
|||||||
B = QPoint(x,y);
|
B = QPoint(x,y);
|
||||||
VectorAB[0] = 0;
|
VectorAB[0] = 0;
|
||||||
VectorAB[1] = 0;
|
VectorAB[1] = 0;
|
||||||
Canvas->image->drawPlain(colorPicker->getFirstColor());
|
|
||||||
Canvas->image->drawPixel(A,LineColor);
|
Canvas->image->drawPixel(A,LineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,14 +29,13 @@ void IntelliToolGradient::onMouseRightPressed(int x, int y){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolGradient::onMouseLeftReleased(int x, int y){
|
void IntelliToolGradient::onMouseLeftReleased(int x, int y){
|
||||||
if(hasMoved && A != B){
|
if(hasMoved){
|
||||||
for(int i = 0; i < activeLayer->height; i++){
|
computeGradientLayer();
|
||||||
for(int j = 0; j < activeLayer->width; j++){
|
IntelliTool::onMouseLeftReleased(x,y);
|
||||||
computePixelColor(QPoint(i,j));
|
}
|
||||||
}
|
else{
|
||||||
}
|
IntelliTool::onMouseRightPressed(x,y);
|
||||||
}
|
}
|
||||||
IntelliTool::onMouseLeftReleased(x,y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolGradient::onMouseRightReleased(int x, int y){
|
void IntelliToolGradient::onMouseRightReleased(int x, int y){
|
||||||
@@ -49,12 +47,11 @@ void IntelliToolGradient::onMouseMoved(int x, int y){
|
|||||||
B = QPoint(x,y);
|
B = QPoint(x,y);
|
||||||
VectorAB[0] = static_cast<float>(B.x() - A.x());
|
VectorAB[0] = static_cast<float>(B.x() - A.x());
|
||||||
VectorAB[1] = static_cast<float>(B.y() - A.y());
|
VectorAB[1] = static_cast<float>(B.y() - A.y());
|
||||||
|
NormalVector[0] = VectorAB[1];
|
||||||
|
NormalVector[1] = (-1*VectorAB[0]);
|
||||||
|
NormalDotNormal = dotProduct(NormalVector,NormalVector);
|
||||||
this->Canvas->image->drawPlain(Qt::transparent);
|
this->Canvas->image->drawPlain(Qt::transparent);
|
||||||
for(int i = 0; i < activeLayer->height; i++){
|
computeGradientLayer();
|
||||||
for(int j = 0; j < activeLayer->width; j++){
|
|
||||||
computePixelColor(QPoint(i,j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Canvas->image->drawLine(A,B,LineColor,1);
|
Canvas->image->drawLine(A,B,LineColor,1);
|
||||||
IntelliTool::onMouseMoved(x,y);
|
IntelliTool::onMouseMoved(x,y);
|
||||||
}
|
}
|
||||||
@@ -64,9 +61,6 @@ void IntelliToolGradient::onWheelScrolled(int value){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolGradient::computePixelColor(QPoint Point){
|
void IntelliToolGradient::computePixelColor(QPoint Point){
|
||||||
double NormalVector[2];
|
|
||||||
NormalVector[0] = VectorAB[1];
|
|
||||||
NormalVector[1] = (-1*VectorAB[0]);
|
|
||||||
double doublePoint[2];
|
double doublePoint[2];
|
||||||
doublePoint[0] = static_cast<double>(Point.x());
|
doublePoint[0] = static_cast<double>(Point.x());
|
||||||
doublePoint[1] = static_cast<double>(Point.y());
|
doublePoint[1] = static_cast<double>(Point.y());
|
||||||
@@ -75,7 +69,6 @@ void IntelliToolGradient::computePixelColor(QPoint Point){
|
|||||||
doublePointSubA[1] = doublePoint[1] - doubleA[1];
|
doublePointSubA[1] = doublePoint[1] - doubleA[1];
|
||||||
double Perpendicular[2];
|
double Perpendicular[2];
|
||||||
double PointSubADotNormal = dotProduct(doublePointSubA,NormalVector);
|
double PointSubADotNormal = dotProduct(doublePointSubA,NormalVector);
|
||||||
double NormalDotNormal = dotProduct(NormalVector,NormalVector);
|
|
||||||
Perpendicular[0] = doublePoint[0] - (PointSubADotNormal / NormalDotNormal) * NormalVector[0];
|
Perpendicular[0] = doublePoint[0] - (PointSubADotNormal / NormalDotNormal) * NormalVector[0];
|
||||||
Perpendicular[1] = doublePoint[1] - (PointSubADotNormal / NormalDotNormal) * NormalVector[1];
|
Perpendicular[1] = doublePoint[1] - (PointSubADotNormal / NormalDotNormal) * NormalVector[1];
|
||||||
double VectorAPoint[2];
|
double VectorAPoint[2];
|
||||||
@@ -120,3 +113,20 @@ double IntelliToolGradient::dotProduct(double Vector1[2], double Vector2[2]){
|
|||||||
double IntelliToolGradient::lenghtVector(double Vector[2]){
|
double IntelliToolGradient::lenghtVector(double Vector[2]){
|
||||||
return static_cast<double>((std::sqrt(Vector[0] * Vector[0] + Vector[1] * Vector[1])));
|
return static_cast<double>((std::sqrt(Vector[0] * Vector[0] + Vector[1] * Vector[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IntelliToolGradient::computeGradientLayer(){
|
||||||
|
bool switched = false;
|
||||||
|
if(Canvas->image->isFastRendering()){
|
||||||
|
switched = true;
|
||||||
|
Canvas->image->updateRendererSetting(false);
|
||||||
|
}
|
||||||
|
qDebug() << activeLayer->width << activeLayer->height;
|
||||||
|
for(int i = 0; i < activeLayer->height; i++){
|
||||||
|
for(int j = 0; j < activeLayer->width; j++){
|
||||||
|
computePixelColor(QPoint(i,j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(switched){
|
||||||
|
Canvas->image->updateRendererSetting(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ class IntelliToolGradient : public IntelliTool{
|
|||||||
private:
|
private:
|
||||||
QPoint A;
|
QPoint A;
|
||||||
QPoint B;
|
QPoint B;
|
||||||
double VectorAB[2];
|
|
||||||
double doubleA[2];
|
double doubleA[2];
|
||||||
|
double VectorAB[2];
|
||||||
|
double NormalVector[2];
|
||||||
|
double NormalDotNormal;
|
||||||
QColor LineColor;
|
QColor LineColor;
|
||||||
bool hasMoved;
|
bool hasMoved;
|
||||||
|
|
||||||
@@ -62,6 +64,8 @@ public:
|
|||||||
double dotProduct(double Vector1[2], double Vector2[2]);
|
double dotProduct(double Vector1[2], double Vector2[2]);
|
||||||
|
|
||||||
double lenghtVector(double Vector[2]);
|
double lenghtVector(double Vector[2]);
|
||||||
|
|
||||||
|
void computeGradientLayer();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTELLITOOLGRADIENT_H
|
#endif // INTELLITOOLGRADIENT_H
|
||||||
|
|||||||
Reference in New Issue
Block a user