Go to the documentation of this file.
9 this->LineColor = QColor(0,0,0,255);
10 this->hasMoved =
false;
19 doubleStartPoint[0] =
static_cast<double>(x);
20 doubleStartPoint[1] =
static_cast<double>(y);
21 startPoint = QPoint(x,y);
22 endPoint = QPoint(x,y);
23 VectorStartEnd[0] = 0;
24 VectorStartEnd[1] = 0;
34 computeGradientLayer();
46 endPoint = QPoint(x,y);
48 computeGradientLayer();
58 void IntelliToolGradient::computeAndDrawPixelColor(QPoint Point,
int FirstColor[4],
int SecondColor[4],
double NormalVector[2],
double NormalDotNormal){
59 double doublePoint[2];
60 doublePoint[0] =
static_cast<double>(Point.x());
61 doublePoint[1] =
static_cast<double>(Point.y());
62 double doublePointSubA[2];
63 doublePointSubA[0] = doublePoint[0] - doubleStartPoint[0];
64 doublePointSubA[1] = doublePoint[1] - doubleStartPoint[1];
65 double Perpendicular[2];
66 double PointSubADotNormal = dotProduct(doublePointSubA,NormalVector);
67 Perpendicular[0] = doublePoint[0] - (PointSubADotNormal / NormalDotNormal) * NormalVector[0];
68 Perpendicular[1] = doublePoint[1] - (PointSubADotNormal / NormalDotNormal) * NormalVector[1];
69 double VectorAPoint[2];
70 VectorAPoint[0] =
static_cast<double>(Perpendicular[0] - doubleStartPoint[0]);
71 VectorAPoint[1] =
static_cast<double>(Perpendicular[1] - doubleStartPoint[1]);
73 if(((VectorAPoint[0] < 0 && VectorStartEnd[0] < 0) || (VectorAPoint[0] > 0 && VectorStartEnd[0] > 0)) && ((VectorAPoint[1] < 0 && VectorStartEnd[1] < 0) || (VectorAPoint[1] > 0 && VectorStartEnd[1] > 0)))
74 ratio = lenghtVector(VectorAPoint) / lenghtVector(VectorStartEnd);
86 computedColor.setRed(
static_cast<int>(ratio * SecondColor[0] + (1 - ratio) * FirstColor[0]));
87 computedColor.setGreen(
static_cast<int>(ratio * SecondColor[1] + (1 - ratio) * FirstColor[1]));
88 computedColor.setBlue(
static_cast<int>(ratio * SecondColor[2] + (1 - ratio) * FirstColor[2]));
89 computedColor.setAlpha(
static_cast<int>(ratio * SecondColor[3] + (1 - ratio) * FirstColor[3]));
94 double IntelliToolGradient::dotProduct(
double Vector1[2],
double Vector2[2]){
95 return static_cast<double>(Vector1[0] * Vector2[0] + Vector1[1] * Vector2[1]);
98 double IntelliToolGradient::lenghtVector(
double Vector[2]){
99 return static_cast<double>((sqrt(Vector[0] * Vector[0] + Vector[1] * Vector[1])));
102 void IntelliToolGradient::computeGradientLayer(){
108 double NormalVector[2];
109 double NormalDotNormal;
111 VectorStartEnd[0] =
static_cast<double>(endPoint.x() - startPoint.x());
112 VectorStartEnd[1] =
static_cast<double>(endPoint.y() - startPoint.y());
113 NormalVector[0] = VectorStartEnd[1];
114 NormalVector[1] = (-1 * VectorStartEnd[0]);
115 NormalDotNormal = dotProduct(NormalVector,NormalVector);
119 computeAndDrawPixelColor(QPoint(j,i), FirstColor, SecondColor, NormalVector, NormalDotNormal);
QColor getFirstColor() const
A function to read the primary selected color.
virtual void drawLine(const QPoint &p1, const QPoint &p2, const QColor &color, const int &penWidth)
A function that draws a line between two given points in a given color.
virtual void drawPixel(const QPoint &p1, const QColor &color)
A funtcion used to draw a pixel on the Image with the given Color.
The PaintingArea class manages the methods and stores information about the current painting area,...
QColor getSecondColor() const
A function to read the secondary selected color.
int width
width - Stores the width of a layer in pixels.
int height
height - Stores the height of a layer in pixels.
The IntelliColorPicker manages the selected colors for one whole project.
IntelliImage * image
image - Stores the imageData of the current LayerObject.
virtual void drawPlain(const QColor &color)
A function that clears the whole image in a given Color.