aboutsummaryrefslogtreecommitdiff
path: root/svg-flatten/include/flatten.hpp
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2021-04-24 17:20:00 +0200
committerjaseg <git@jaseg.de>2021-04-24 20:17:42 +0200
commit776e0bd2069af0cfff7ce794cf3b345b613e1c02 (patch)
tree04d63001eee0ed741bd6869901610ee1b1603dd2 /svg-flatten/include/flatten.hpp
parent89da2b3664ec75cf5de1e5d7ee48acd0f2847df8 (diff)
downloadgerbolyze-776e0bd2069af0cfff7ce794cf3b345b613e1c02.tar.gz
gerbolyze-776e0bd2069af0cfff7ce794cf3b345b613e1c02.tar.bz2
gerbolyze-776e0bd2069af0cfff7ce794cf3b345b613e1c02.zip
Replace cairo curve flattener from Anitgrain Graphics
This also fixes an issue where non-closed curves were not dilated properly.
Diffstat (limited to 'svg-flatten/include/flatten.hpp')
-rw-r--r--svg-flatten/include/flatten.hpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/svg-flatten/include/flatten.hpp b/svg-flatten/include/flatten.hpp
new file mode 100644
index 0000000..b620890
--- /dev/null
+++ b/svg-flatten/include/flatten.hpp
@@ -0,0 +1,27 @@
+
+#include "gerbolyze.hpp"
+
+namespace gerbolyze {
+ class curve4_div {
+ public:
+ curve4_div(double distance_tolerance=0.1, double angle_tolerance=0.0, double cusp_limit=0.0)
+ : m_distance_tolerance_square(0.25*distance_tolerance*distance_tolerance),
+ m_angle_tolerance(angle_tolerance),
+ m_cusp_limit(cusp_limit)
+ {
+ }
+
+ void run(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
+ const std::vector<d2p> &points() { return m_points; }
+
+ private:
+ void recursive_bezier(double x1, double y1, double x2, double y2,
+ double x3, double y3, double x4, double y4,
+ unsigned level);
+ double m_cusp_limit;
+ double m_distance_tolerance_square;
+ double m_angle_tolerance;
+ std::vector<d2p> m_points;
+ };
+}
+