Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_polygonal_gradient_shape_strategy.cpp File Reference
#include "kis_polygonal_gradient_shape_strategy.h"
#include "kis_debug.h"
#include "kis_algebra_2d.h"
#include <config-gsl.h>
#include <QtCore/qmath.h>
#include <limits>
#include <boost/math/distributions/normal.hpp>
#include <QPainterPath>
#include "krita_utils.h"

Go to the source code of this file.

Namespaces

namespace  Private
 

Functions

qreal Private::calculateMaxWeight (const QPainterPath &selectionPath, qreal exponent, bool searchForMax)
 
QPointF Private::centerFromPath (const QPainterPath &selectionPath)
 
bool Private::findBestStartingPoint (int numSamples, const QPainterPath &path, qreal exponent, bool searchForMax, qreal initialExtremumValue, QPointF *result)
 
qreal Private::getDisnormedGradientValue (const QPointF &pt, const QPainterPath &selectionPath, qreal exponent)
 
qreal Private::initialExtremumValue (bool searchForMax)
 
QPainterPath simplifyPath (const QPainterPath &path, qreal sizePortion, qreal minLinearSize, int minNumSamples)
 

Function Documentation

◆ simplifyPath()

QPainterPath simplifyPath ( const QPainterPath & path,
qreal sizePortion,
qreal minLinearSize,
int minNumSamples )

Definition at line 318 of file kis_polygonal_gradient_shape_strategy.cpp.

322{
323 QPainterPath finalPath;
324
325 QList<QPolygonF> polygons = path.toSubpathPolygons();
326 Q_FOREACH (const QPolygonF poly, polygons) {
327 QPainterPath p;
328 p.addPolygon(poly);
329
330 const qreal length = p.length();
331 const qreal lengthStep =
332 KritaUtils::maxDimensionPortion(poly.boundingRect(),
333 sizePortion, minLinearSize);
334
335 int numSamples = qMax(qCeil(length / lengthStep), minNumSamples);
336
337 if (numSamples > poly.size()) {
338 finalPath.addPolygon(poly);
339 finalPath.closeSubpath();
340 continue;
341 }
342
343 const qreal portionStep = 1.0 / numSamples;
344
345 QPolygonF newPoly;
346 for (qreal t = 0.0; t < 1.0; t += portionStep) {
347 newPoly << p.pointAtPercent(t);
348 }
349
350 finalPath.addPolygon(newPoly);
351 finalPath.closeSubpath();
352 }
353
354 return finalPath;
355}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
const Params2D p
qreal KRITAIMAGE_EXPORT maxDimensionPortion(const QRectF &bounds, qreal portion, qreal minValue)

References length(), KritaUtils::maxDimensionPortion(), and p.