Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCurveFit.h File Reference
#include <QList>
#include <QPointF>
#include "kritaflake_export.h"

Go to the source code of this file.

Functions

KRITAFLAKE_EXPORT KoPathShapebezierFit (const QList< QPointF > &points, float error)
 

Function Documentation

◆ bezierFit()

KRITAFLAKE_EXPORT KoPathShape * bezierFit ( const QList< QPointF > & points,
float error )

Definition at line 543 of file KoCurveFit.cpp.

544{
545 FitVector tHat1, tHat2;
546
547 tHat1 = ComputeLeftTangent(points, 0);
548 tHat2 = ComputeRightTangent(points, points.count() - 1);
549
550 int width = 0;
551 QPointF *curve;
552 curve = FitCubic(points, 0, points.count() - 1, tHat1, tHat2, error, width);
553
554 KoPathShape * path = new KoPathShape();
555
556 if (width > 3) {
557 path->moveTo(curve[0]);
558 path->curveTo(curve[1], curve[2], curve[3]);
559 for (int i = 4; i < width; i += 4) {
560 path->curveTo(curve[i+1], curve[i+2], curve[i+3]);
561 }
562 }
563
564 delete[] curve;
565 return path;
566}
FitVector ComputeLeftTangent(const QList< QPointF > &points, int end)
FitVector ComputeRightTangent(const QList< QPointF > &points, int end)
QPointF * FitCubic(const QList< QPointF > &points, int first, int last, FitVector tHat1, FitVector tHat2, float error, int &width)
The position of a path point within a path shape.
Definition KoPathShape.h:63

References ComputeLeftTangent(), ComputeRightTangent(), and FitCubic().