summaryrefslogtreecommitdiffstats
path: root/src/live_effects/spiro-converters.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/live_effects/spiro-converters.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 'src/live_effects/spiro-converters.h')
-rw-r--r--src/live_effects/spiro-converters.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/live_effects/spiro-converters.h b/src/live_effects/spiro-converters.h
new file mode 100644
index 0000000..98041a2
--- /dev/null
+++ b/src/live_effects/spiro-converters.h
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/** @file
+ * TODO: insert short description here
+ *//*
+ * Authors: see git history
+ *
+ * Copyright (C) 2018 Authors
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+#ifndef INKSCAPE_SPIRO_CONVERTERS_H
+#define INKSCAPE_SPIRO_CONVERTERS_H
+
+#include <2geom/forward.h>
+class SPCurve;
+
+namespace Spiro {
+
+class ConverterBase {
+public:
+ ConverterBase() = default;;
+ virtual ~ConverterBase() = default;;
+
+ virtual void moveto(double x, double y) = 0;
+ virtual void lineto(double x, double y, bool close_last) = 0;
+ virtual void quadto(double x1, double y1, double x2, double y2, bool close_last) = 0;
+ virtual void curveto(double x1, double y1, double x2, double y2, double x3, double y3, bool close_last) = 0;
+};
+
+
+/**
+ * Converts Spiro to Inkscape's SPCurve
+ */
+class ConverterSPCurve : public ConverterBase {
+public:
+ ConverterSPCurve(SPCurve &curve)
+ : _curve(curve)
+ {}
+
+ void moveto(double x, double y) override;
+ void lineto(double x, double y, bool close_last) override;
+ void quadto(double x1, double y1, double x2, double y2, bool close_last) override;
+ void curveto(double x1, double y1, double x2, double y2, double x3, double y3, bool close_last) override;
+
+private:
+ SPCurve &_curve;
+
+ ConverterSPCurve(const ConverterSPCurve&) = delete;
+ ConverterSPCurve& operator=(const ConverterSPCurve&) = delete;
+};
+
+
+/**
+ * Converts Spiro to 2Geom's Path
+ */
+class ConverterPath : public ConverterBase {
+public:
+ ConverterPath(Geom::Path &path);
+
+ void moveto(double x, double y) override;
+ void lineto(double x, double y, bool close_last) override;
+ void quadto(double x1, double y1, double x2, double y2, bool close_last) override;
+ void curveto(double x1, double y1, double x2, double y2, double x3, double y3, bool close_last) override;
+
+private:
+ Geom::Path &_path;
+
+ ConverterPath(const ConverterPath&) = delete;
+ ConverterPath& operator=(const ConverterPath&) = delete;
+};
+
+
+} // namespace Spiro
+
+#endif