summaryrefslogtreecommitdiffstats
path: root/src/helper/geom-curves.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/helper/geom-curves.h
parentInitial commit. (diff)
downloadinkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz
inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/helper/geom-curves.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/helper/geom-curves.h b/src/helper/geom-curves.h
new file mode 100644
index 0000000..08403e2
--- /dev/null
+++ b/src/helper/geom-curves.h
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef INKSCAPE_HELPER_GEOM_CURVES_H
+#define INKSCAPE_HELPER_GEOM_CURVES_H
+
+/**
+ * @file
+ * Specific curve type functions for Inkscape, not provided by lib2geom.
+ */
+/*
+ * Author:
+ * Johan Engelen <goejendaagh@zonnet.nl>
+ *
+ * Copyright (C) 2008-2009 Johan Engelen
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#include <2geom/line.h>
+#include <2geom/bezier-curve.h>
+
+/// \todo un-inline this function
+inline bool is_straight_curve(Geom::Curve const & c)
+{
+ if( dynamic_cast<Geom::LineSegment const*>(&c) )
+ {
+ return true;
+ }
+ // the curve can be a quad/cubic bezier, but could still be a perfect straight line
+ // if the control points are exactly on the line connecting the initial and final points.
+ Geom::BezierCurve const *curve = dynamic_cast<Geom::BezierCurve const *>(&c);
+ if (curve) {
+ Geom::Line line(curve->initialPoint(), curve->finalPoint());
+ std::vector<Geom::Point> pts = curve->controlPoints();
+ for (unsigned i = 1; i < pts.size() - 1; ++i) {
+ if (!are_near(pts[i], line))
+ return false;
+ }
+ return true;
+ }
+
+ return false;
+}
+
+#endif // INKSCAPE_HELPER_GEOM_CURVES_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :