File indexing completed on 2024-12-22 04:09:07
0001 /* 0002 * SPDX-FileCopyrightText: Copyright (c) 2011 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KOPOLYGONUTILS_H 0008 #define KOPOLYGONUTILS_H 0009 0010 #include <QPolygon> 0011 0012 /** 0013 * @brief The KoPolygonUtils class 0014 * 0015 * This class allows us to use the Polygon Concept from boost for QPolygons, which 0016 * has a very fast polygon offset algorithm, necessary for text-padding. 0017 * 0018 * For more info see: 0019 * https://www.boost.org/doc/libs/1_81_0/libs/polygon/doc/gtl_polygon_set_concept.htm 0020 */ 0021 0022 class KoPolygonUtils 0023 { 0024 public: 0025 /** 0026 * @brief offsetPolygon 0027 * This offsets a single polygon, using the winding/nonzero fill-rule to determine inside and outside. 0028 * 0029 * @param polygon 0030 * @param offset 0031 * the offset. 0032 * @param rounded 0033 * whether the edges are rounded. 0034 * @param circleSegments 0035 * segments in a 360° circle. 0036 * @return the offset polygon. 0037 */ 0038 static QPolygon offsetPolygon(const QPolygon &polygon, int offset, bool rounded = true, int circleSegments = 16); 0039 0040 static QList<QPolygon> offsetPolygons (const QList<QPolygon> polygons, int offset, bool rounded = true, int circleSegments = 16); 0041 }; 0042 0043 #endif // KOPOLYGONUTILS_H