mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
Wechsel Rechner
This commit is contained in:
@@ -30,6 +30,7 @@ SOURCES += \
|
|||||||
Tool/IntelliTool.cpp \
|
Tool/IntelliTool.cpp \
|
||||||
Tool/IntelliToolCircle.cpp \
|
Tool/IntelliToolCircle.cpp \
|
||||||
Tool/IntelliToolFloodFill.cpp \
|
Tool/IntelliToolFloodFill.cpp \
|
||||||
|
Tool/IntelliToolGradient.cpp \
|
||||||
Tool/IntelliToolLine.cpp \
|
Tool/IntelliToolLine.cpp \
|
||||||
Tool/IntelliToolPen.cpp \
|
Tool/IntelliToolPen.cpp \
|
||||||
Tool/IntelliToolPlain.cpp \
|
Tool/IntelliToolPlain.cpp \
|
||||||
@@ -52,6 +53,7 @@ HEADERS += \
|
|||||||
Tool/IntelliTool.h \
|
Tool/IntelliTool.h \
|
||||||
Tool/IntelliToolCircle.h \
|
Tool/IntelliToolCircle.h \
|
||||||
Tool/IntelliToolFloodFill.h \
|
Tool/IntelliToolFloodFill.h \
|
||||||
|
Tool/IntelliToolGradient.h \
|
||||||
Tool/IntelliToolLine.h \
|
Tool/IntelliToolLine.h \
|
||||||
Tool/IntelliToolPen.h \
|
Tool/IntelliToolPen.h \
|
||||||
Tool/IntelliToolPlain.h \
|
Tool/IntelliToolPlain.h \
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "Tool/IntelliToolRectangle.h"
|
#include "Tool/IntelliToolRectangle.h"
|
||||||
#include "Tool/IntelliToolFloodFill.h"
|
#include "Tool/IntelliToolFloodFill.h"
|
||||||
#include "Tool/IntelliToolPolygon.h"
|
#include "Tool/IntelliToolPolygon.h"
|
||||||
|
#include "Tool/IntelliToolGradient.h"
|
||||||
#include "GUI/IntelliPhotoGui.h"
|
#include "GUI/IntelliPhotoGui.h"
|
||||||
|
|
||||||
LayerObject::LayerObject(){
|
LayerObject::LayerObject(){
|
||||||
@@ -38,9 +39,8 @@ LayerObject::LayerObject(const LayerObject& layer){
|
|||||||
|
|
||||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
|
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
|
||||||
: QLabel(parent){
|
: QLabel(parent){
|
||||||
this->Tool = nullptr;
|
this->Tool = new IntelliToolGradient(this,&colorPicker,&Toolsettings);
|
||||||
this->setLayerDimensions(maxWidth, maxHeight);
|
this->setLayerDimensions(maxWidth, maxHeight);
|
||||||
|
|
||||||
activeLayer = -1;
|
activeLayer = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
61
src/Tool/IntelliToolGradient.cpp
Normal file
61
src/Tool/IntelliToolGradient.cpp
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#include "IntelliToolGradient.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
IntelliToolGradient::IntelliToolGradient(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
|
||||||
|
: IntelliTool(Area, colorPicker, Toolsettings){
|
||||||
|
this->LineColor = QColor(0,0,0,255);
|
||||||
|
this->hasMoved = false;
|
||||||
|
|
||||||
|
A = QPoint(0,0);
|
||||||
|
B = QPoint(0,3);
|
||||||
|
VectorAB = QPoint(0,3);
|
||||||
|
computePixelColor(QPoint(2,1));
|
||||||
|
}
|
||||||
|
|
||||||
|
IntelliToolGradient::~IntelliToolGradient(){
|
||||||
|
IntelliTool::onMouseRightPressed(0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolGradient::onMouseLeftPressed(int x, int y){
|
||||||
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
|
A = QPoint(x,y);
|
||||||
|
B = QPoint(x,y);
|
||||||
|
VectorAB = QPoint(0,0);
|
||||||
|
//Canvas->image->drawPlain(colorPicker->getFirstColor);
|
||||||
|
//Canvas->image->drawPixel(A,LineColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolGradient::onMouseRightPressed(int x, int y){
|
||||||
|
IntelliTool::onMouseRightPressed(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolGradient::onMouseLeftReleased(int x, int y){
|
||||||
|
if(!hasMoved && A != B){
|
||||||
|
//Canvas->image->drawPlain(colorPicker->getFirstColor);
|
||||||
|
}
|
||||||
|
IntelliTool::onMouseLeftReleased(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolGradient::onMouseRightReleased(int x, int y){
|
||||||
|
IntelliTool::onMouseRightReleased(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolGradient::onMouseMoved(int x, int y){
|
||||||
|
hasMoved = true;
|
||||||
|
B = QPoint(x,y);
|
||||||
|
IntelliTool::onMouseMoved(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolGradient::onWheelScrolled(int value){
|
||||||
|
IntelliTool::onWheelScrolled(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolGradient::computePixelColor(QPoint Point){
|
||||||
|
QPoint NormalVector = QPoint(VectorAB.y(),(-1*VectorAB.x()));
|
||||||
|
Point = Point - (dotProduct((Point - A),NormalVector) / dotProduct(NormalVector,NormalVector)) * NormalVector;
|
||||||
|
qDebug() << Point.y();
|
||||||
|
}
|
||||||
|
|
||||||
|
float IntelliToolGradient::dotProduct(QPoint Vector1, QPoint Vector2){
|
||||||
|
return static_cast<float>(Vector1.x()*Vector2.x()+Vector1.y()*Vector2.y());
|
||||||
|
}
|
||||||
64
src/Tool/IntelliToolGradient.h
Normal file
64
src/Tool/IntelliToolGradient.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#ifndef INTELLITOOLGRADIENT_H
|
||||||
|
#define INTELLITOOLGRADIENT_H
|
||||||
|
#include "IntelliTool.h"
|
||||||
|
|
||||||
|
class IntelliToolGradient : public IntelliTool{
|
||||||
|
private:
|
||||||
|
QPoint A;
|
||||||
|
QPoint B;
|
||||||
|
QPoint VectorAB;
|
||||||
|
QColor LineColor;
|
||||||
|
bool hasMoved;
|
||||||
|
|
||||||
|
public:
|
||||||
|
IntelliToolGradient(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings);
|
||||||
|
|
||||||
|
~IntelliToolGradient();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on. Call this in child classes!
|
||||||
|
* \param x - The x coordinate relative to the active/canvas layer.
|
||||||
|
* \param y - The y coordinate relative to the active/canvas layer.
|
||||||
|
*/
|
||||||
|
virtual void onMouseRightPressed(int x, int y);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A function managing the right click Released of a Mouse. Merging the Canvas to Active. Call this in child classes!
|
||||||
|
* \param x - The x coordinate relative to the active/canvas layer.
|
||||||
|
* \param y - The y coordinate relative to the active/canvas layer.
|
||||||
|
*/
|
||||||
|
virtual void onMouseRightReleased(int x, int y);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A function managing the left click Pressed of a Mouse. Resetting the current draw. Call this in child classes!
|
||||||
|
* \param x - The x coordinate relative to the active/canvas layer.
|
||||||
|
* \param y - The y coordinate relative to the active/canvas layer.
|
||||||
|
*/
|
||||||
|
virtual void onMouseLeftPressed(int x, int y);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A function managing the left click Released of a Mouse. Call this in child classes!
|
||||||
|
* \param x - The x coordinate relative to the active/canvas layer.
|
||||||
|
* \param y - The y coordinate relative to the active/canvas layer.
|
||||||
|
*/
|
||||||
|
virtual void onMouseLeftReleased(int x, int y);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A function managing the scroll event. A positive value means scrolling outwards. Call this in child classes!
|
||||||
|
* \param value - The absolute the scroll has changed.
|
||||||
|
*/
|
||||||
|
virtual void onWheelScrolled(int value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A function managing the mouse moved event. Call this in child classes!
|
||||||
|
* \param x - The x coordinate of the new mouse position.
|
||||||
|
* \param y - The y coordinate of the new mouse position.
|
||||||
|
*/
|
||||||
|
virtual void onMouseMoved(int x, int y);
|
||||||
|
|
||||||
|
void computePixelColor(QPoint Point);
|
||||||
|
|
||||||
|
float dotProduct(QPoint Vector1, QPoint Vector2);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INTELLITOOLGRADIENT_H
|
||||||
Reference in New Issue
Block a user