59 QPainterPath baseGuidePath;
60 QPainterPath mouseGuidePath;
62 gc.setTransform(initialTransform);
85 double deltaX =
p2.x() -
p1.x();
86 double deltaY =
p2.y() -
p1.y();
92 QGradient fade = QLinearGradient(
93 QPointF(
p1.x() - deltaY,
p1.y() + deltaX),
94 QPointF(
p1.x() + deltaY,
p1.y() - deltaX));
98 fade.setColorAt(0.5, color);
100 const QPen pen = gc.pen();
101 const QBrush new_brush = QBrush(fade);
103 const QPen new_pen = QPen(new_brush, width, pen.style());
107 double halfHandleDist = handleDistance / 2.0;
109 double avgX = deltaX / 2.0 +
p1.x();
110 double avgY = deltaY / 2.0 +
p1.y();
114 double dirX = -deltaY / handleDistance;
115 double dirY = deltaX / handleDistance;
117 int resolution = halfHandleDist / 3;
119 if(assistantVisible) {
121 for(
int i = -resolution; i < resolution; i++) {
124 baseGuidePath.moveTo(QPointF(
p1.x() - deltaX*2,
p1.y() - deltaY*2));
125 baseGuidePath.lineTo(QPointF(
p2.x() + deltaX*2,
p2.y() + deltaY*2));
129 double mult = 1.0 / i;
131 double centerDist = halfHandleDist * (1 -
pow2(mult)) / (2*mult);
134 double circleCenterX = centerDist * dirX + avgX;
135 double circleCenterY = centerDist * dirY + avgY;
137 double radius = halfHandleDist * (1 +
pow2(mult)) / (2*mult);
139 baseGuidePath.addEllipse(QPointF(circleCenterX, circleCenterY), radius, radius);
142 gc.drawPath(baseGuidePath);
149 QPointF screenP1 = initialTransform.map(*
handles()[0]);
150 QPointF screenP2 = initialTransform.map(*
handles()[1]);
157 QLineF circle =
identifyCircle(initialTransform.inverted().map(mousePos));
158 double radius = circle.length();
159 mouseGuidePath.addEllipse(circle.p1(), radius, radius);
162 gc.drawPath(mouseGuidePath);
197 double deltaX =
p2.x() -
p1.x();
198 double deltaY =
p2.y() -
p1.y();
201 double halfHandleDist = handleDistance / 2.0;
203 double avgX = deltaX / 2.0 +
p1.x();
204 double avgY = deltaY / 2.0 +
p1.y();
206 double dirX = -deltaY / handleDistance;
207 double dirY = deltaX / handleDistance;
209 double betaX = thirdPoint.x() - avgX;
210 double betaY = thirdPoint.y() - avgY;
215 (2 * dirX * betaX + 2 * dirY * betaY);
217 double circleCenterX = centerDist*dirX + avgX;
218 double circleCenterY = centerDist*dirY + avgY;
219 return QLineF(QPointF(circleCenterX, circleCenterY), thirdPoint);
void drawAssistant(QPainter &gc, const QRectF &updateRect, const KisCoordinatesConverter *converter, bool cached=true, KisCanvas2 *canvas=0, bool assistantVisible=true, bool previewVisible=true) override