13#include <QPainterPath>
78 m_path.setFillRule(Qt::WindingFill);
84 Q_FOREACH (
const QRect &
rect, changedRegion.
rects()) {
97 Q_FOREACH (
const QRect &
rect, changedRegion.
rects()) {
106 const qreal fadeFactor = 0.6;
108 QPointF diff = pi2.
pos() - pi1.
pos();
109 qreal realLength = sqrt(diff.x() * diff.x() + diff.y() * diff.y());
111 if (realLength < 0.1)
return pi2.
pos();
123 Q_UNUSED(currentDistance);
146 const QPointF pos1 = pi1.
pos();
147 QPointF pos2 = pi2.
pos();
153 int length = (pos2 - pos1).manhattanLength();
181 if (
m_path.elementCount() % 16 == 0) {
197 const int timeThreshold = 40;
200 QRect pathBounds =
m_path.boundingRect().toRect();
201 int distanceMetric = qMax(pathBounds.width(), pathBounds.height());
203 if (elapsedTime > timeThreshold ||
216 const int pathSizeThreshold = 128;
219 if (distanceMetric < pathSizeThreshold) {
223 changedRect.adjust(-1, -1, 1, 1);
225 changedRegion = changedRect.toRect();
262 const QPointF &startPoint,
263 const QPointF &endPoint,
265 qreal distanceThreshold,
268 qreal
length = (endPoint - startPoint).manhattanLength();
270 if (lastSegment ||
length > distanceThreshold) {
272 path.lineTo(startPoint);
281 path.lineTo(endPoint);
290 qreal maxDimension = qMax(
bounds.width(),
bounds.height());
291 return qMax(0.01 * maxDimension, 1.0);
296 QPointF diff =
p1 -
p2;
297 qreal realLength = sqrt(diff.x() * diff.x() + diff.y() * diff.y());
298 return realLength > 0.5 ?
p1 + diff *
distance / realLength :
p1;
303 QPointF lastPoint = path.currentPosition();
305 QPainterPath newPath;
306 int count = path.elementCount();
307 int curveElementCounter = 0;
311 for (
int i = 0; i < count; i++) {
312 QPainterPath::Element e = path.elementAt(i);
314 case QPainterPath::MoveToElement: {
315 newPath.moveTo(
getAngle(QPointF(e.x, e.y), lastPoint, speed));
318 case QPainterPath::LineToElement: {
319 newPath.lineTo(
getAngle(QPointF(e.x, e.y), lastPoint, speed));
322 case QPainterPath::CurveToElement: {
323 curveElementCounter = 0;
324 endPoint =
getAngle(QPointF(e.x, e.y), lastPoint, speed);
327 case QPainterPath::CurveToDataElement: {
328 curveElementCounter++;
330 if (curveElementCounter == 1) {
331 ctrl1 =
getAngle(QPointF(e.x, e.y), lastPoint, speed);
333 else if (curveElementCounter == 2) {
334 ctrl2 =
getAngle(QPointF(e.x, e.y), lastPoint, speed);
335 newPath.cubicTo(ctrl1, ctrl2, endPoint);
qreal length(const QPointF &vec)
const QString COMPOSITE_COPY
qreal distance(const QPointF &p1, const QPointF &p2)
void paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance) override
KisPaintDeviceSP m_originalDevice
KisSpacingInformation paintAt(const KisPaintInformation &info) override
~KisExperimentPaintOp() override
QPointF m_savedSpeedPoint
QVector< QPointF > m_savedPoints
QPainterPath m_lastPaintedPath
KisPainter * m_originalPainter
KisPainter::FillStyle m_fillStyle
QPointF speedCorrectedPosition(const KisPaintInformation &pi1, const KisPaintInformation &pi2)
int m_savedSmoothingDistance
KisExperimentPaintOp(const KisPaintOpSettingsSP settings, KisPainter *painter, KisNodeSP node, KisImageSP image)
QPointF m_savedSmoothingPoint
int m_savedUpdateDistance
static qreal simplifyThreshold(const QRectF &bounds)
KisExperimentOpOptionData m_experimentOption
void paintRegion(const KisRegion &changedRegion)
KisSpacingInformation updateSpacingImpl(const KisPaintInformation &info) const override
static QPointF getAngle(const QPointF &p1, const QPointF &p2, qreal distance)
static QPainterPath applyDisplace(const QPainterPath &path, int speed)
KisPaintDeviceSP createCompositionSourceDevice() const
@ FillStyleForegroundColor
bool hasMirroring() const
void renderDabWithMirroringNonIncremental(QRect rc, KisPaintDeviceSP dab)
void setFillStyle(FillStyle fillStyle)
Set the current style with which to fill.
void fillPainterPath(const QPainterPath &path)
void setPattern(const KoPatternSP pattern)
Set the current pattern.
void setPaintColor(const KoColor &color)
void setAntiAliasPolygonFill(bool antiAliasPolygonFill)
Set whether a polygon's filled area should be anti-aliased or not. The default is true.
void setCompositeOpId(const KoCompositeOp *op)
QRect boundingRect() const
QVector< QRect > rects() const
bool tryMergePoints(QPainterPath &path, const QPointF &startPoint, const QPointF &endPoint, qreal &distance, qreal distanceThreshold, bool lastSegment)
QPainterPath trySimplifyPath(const QPainterPath &path, qreal lengthThreshold)
KisRegion splitPath(const QPainterPath &path)
KisRegion splitTriangles(const QPointF ¢er, const QVector< QPointF > &points)
bool isDisplacementEnabled
bool read(const KisPropertiesConfiguration *setting)
ExperimentFillType fillType
KisPaintDeviceSP source() const