62 QPainterPath baseGuidePath;
63 QPainterPath mouseGuidePath;
65 gc.setTransform(initialTransform);
88 double deltaX =
p2.x() -
p1.x();
89 double deltaY =
p2.y() -
p1.y();
94 QColor color = canvasAssistantColor;
95 QGradient fade = QLinearGradient(
96 QPointF(
p1.x() - deltaY,
p1.y() + deltaX),
97 QPointF(
p1.x() + deltaY,
p1.y() - deltaX));
100 fade.setColorAt(0.42, canvasAssistantColor);
101 fade.setColorAt(0.5, color);
102 fade.setColorAt(0.58, canvasAssistantColor);
103 const QPen pen = gc.pen();
104 const QBrush new_brush = QBrush(fade);
106 const QPen new_pen = QPen(new_brush, width, pen.style());
110 double halfHandleDist = handleDistance / 2.0;
112 double avgX = deltaX / 2.0 +
p1.x();
113 double avgY = deltaY / 2.0 +
p1.y();
117 double dirX = -deltaY / handleDistance;
118 double dirY = deltaX / handleDistance;
120 int resolution = halfHandleDist / 3;
122 if(assistantVisible) {
124 for(
int i = -resolution; i < resolution; i++) {
127 baseGuidePath.moveTo(QPointF(
p1.x() - deltaX*2,
p1.y() - deltaY*2));
128 baseGuidePath.lineTo(QPointF(
p2.x() + deltaX*2,
p2.y() + deltaY*2));
132 double mult = 1.0 / i;
134 double centerDist = halfHandleDist * (1 -
pow2(mult)) / (2*mult);
137 double circleCenterX = centerDist * dirX + avgX;
138 double circleCenterY = centerDist * dirY + avgY;
140 double radius = halfHandleDist * (1 +
pow2(mult)) / (2*mult);
142 baseGuidePath.addEllipse(QPointF(circleCenterX, circleCenterY), radius, radius);
145 gc.drawPath(baseGuidePath);
152 QPointF screenP1 = initialTransform.map(*
handles()[0]);
153 QPointF screenP2 = initialTransform.map(*
handles()[1]);
160 QLineF circle =
identifyCircle(initialTransform.inverted().map(mousePos));
161 double radius = circle.length();
162 mouseGuidePath.addEllipse(circle.p1(), radius, radius);
165 gc.drawPath(mouseGuidePath);
201 double deltaX =
p2.x() -
p1.x();
202 double deltaY =
p2.y() -
p1.y();
205 double halfHandleDist = handleDistance / 2.0;
207 double avgX = deltaX / 2.0 +
p1.x();
208 double avgY = deltaY / 2.0 +
p1.y();
210 double dirX = -deltaY / handleDistance;
211 double dirY = deltaX / handleDistance;
213 double betaX = thirdPoint.x() - avgX;
214 double betaY = thirdPoint.y() - avgY;
219 (2 * dirX * betaX + 2 * dirY * betaY);
221 double circleCenterX = centerDist*dirX + avgX;
222 double circleCenterY = centerDist*dirY + avgY;
223 return QLineF(QPointF(circleCenterX, circleCenterY), thirdPoint);
void drawCache(QPainter &gc, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool assistantVisible=true) override
performance layer where the graphics can be drawn from a cache instead of generated every render upda...
void drawAssistant(QPainter &gc, const QRectF &updateRect, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool cached=true, KisCanvas2 *canvas=0, bool assistantVisible=true, bool previewVisible=true) override