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);
47 VectorStartEnd[0] =
static_cast<float>(endPoint.x() - startPoint.x());
48 VectorStartEnd[1] =
static_cast<float>(endPoint.y() - startPoint.y());
49 NormalVector[0] = VectorStartEnd[1];
50 NormalVector[1] = (-1 * VectorStartEnd[0]);
51 NormalDotNormal = dotProduct(NormalVector,NormalVector);
53 computeGradientLayer();
63 void IntelliToolGradient::computeAndDrawPixelColor(QPoint Point){
64 double doublePoint[2];
65 doublePoint[0] =
static_cast<double>(Point.x());
66 doublePoint[1] =
static_cast<double>(Point.y());
67 double doublePointSubA[2];
68 doublePointSubA[0] = doublePoint[0] - doubleStartPoint[0];
69 doublePointSubA[1] = doublePoint[1] - doubleStartPoint[1];
70 double Perpendicular[2];
71 double PointSubADotNormal = dotProduct(doublePointSubA,NormalVector);
72 Perpendicular[0] = doublePoint[0] - (PointSubADotNormal / NormalDotNormal) * NormalVector[0];
73 Perpendicular[1] = doublePoint[1] - (PointSubADotNormal / NormalDotNormal) * NormalVector[1];
74 double VectorAPoint[2];
75 VectorAPoint[0] =
static_cast<double>(Perpendicular[0] - doubleStartPoint[0]);
76 VectorAPoint[1] =
static_cast<double>(Perpendicular[1] - doubleStartPoint[1]);
78 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)))
79 ratio = lenghtVector(VectorAPoint) / lenghtVector(VectorStartEnd);
101 computedColor.setRed(
static_cast<int>(ratio * red2 + (1 - ratio) * red));
102 computedColor.setGreen(
static_cast<int>(ratio * green2 + (1 - ratio) * green));
103 computedColor.setBlue(
static_cast<int>(ratio * blue2 + (1 - ratio) * blue));
104 computedColor.setAlpha(
static_cast<int>(ratio * alpha2 + (1 - ratio) * alpha));
109 double IntelliToolGradient::dotProduct(
double Vector1[2],
double Vector2[2]){
110 return static_cast<double>(Vector1[0] * Vector2[0] + Vector1[1] * Vector2[1]);
113 double IntelliToolGradient::lenghtVector(
double Vector[2]){
114 return static_cast<double>((sqrt(Vector[0] * Vector[0] + Vector[1] * Vector[1])));
117 void IntelliToolGradient::computeGradientLayer(){
118 bool switched =
false;
125 computeAndDrawPixelColor(QPoint(j,i));
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.
virtual bool isFastRendering() const
isFastRendering returns if the Image is in fast rendering mode.
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.
virtual void updateRendererSetting(bool fastRendererOn)
updateRendererSetting updates the existing image format to the new format.
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.