Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPolygonUtils Class Reference

The KoPolygonUtils class. More...

#include <KoPolygonUtils.h>

Static Public Member Functions

static QPolygon offsetPolygon (const QPolygon &polygon, int offset, bool rounded=true, int circleSegments=16)
 offsetPolygon This offsets a single polygon, using the winding/nonzero fill-rule to determine inside and outside.
 
static QList< QPolygon > offsetPolygons (const QList< QPolygon > polygons, int offset, bool rounded=true, int circleSegments=16)
 

Detailed Description

The KoPolygonUtils class.

This class allows us to use the Polygon Concept from boost for QPolygons, which has a very fast polygon offset algorithm, necessary for text-padding.

For more info see: https://www.boost.org/doc/libs/1_81_0/libs/polygon/doc/gtl_polygon_set_concept.htm

Definition at line 22 of file KoPolygonUtils.h.

Member Function Documentation

◆ offsetPolygon()

QPolygon KoPolygonUtils::offsetPolygon ( const QPolygon & polygon,
int offset,
bool rounded = true,
int circleSegments = 16 )
static

offsetPolygon This offsets a single polygon, using the winding/nonzero fill-rule to determine inside and outside.

Parameters
polygon
offsetthe offset.
roundedwhether the edges are rounded.
circleSegmentssegments in a 360° circle.
Returns
the offset polygon.

Definition at line 95 of file KoPolygonUtils.cpp.

96{
97 PolygonSet polygonSet;
98 polygonSet.push_back(polygon);
99 boost::polygon::resize(polygonSet, offset, rounded, circleSegments);
100 return polygonSet[0];
101}
std::vector< QPolygon > PolygonSet

◆ offsetPolygons()

QList< QPolygon > KoPolygonUtils::offsetPolygons ( const QList< QPolygon > polygons,
int offset,
bool rounded = true,
int circleSegments = 16 )
static

Definition at line 103 of file KoPolygonUtils.cpp.

104{
105 PolygonSet polygonSet;
106 Q_FOREACH(QPolygon polygon, polygons) {
107 polygonSet.push_back(polygon);
108 }
109 boost::polygon::resize(polygonSet, offset, rounded, circleSegments);
110
111 QList<QPolygon> finalPolygons;
112 for (int i=0; i < int(polygonSet.size()); i++) {
113 finalPolygons.append(polygonSet.at(i));
114 }
115 return finalPolygons;
116}

The documentation for this class was generated from the following files: