diff options
author | jaseg <git@jaseg.de> | 2022-06-20 10:24:26 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-06-20 10:24:26 +0200 |
commit | d09cf6ef3b6ea82f7ff67719527cd563569e0893 (patch) | |
tree | 4175218f4fdd6a1a36c8fd835c87639353a3c1c5 /svg-flatten/include/geom2d.hpp | |
parent | f58cca0ba66e66e924caf96545a348584d4f48ee (diff) | |
download | gerbolyze-d09cf6ef3b6ea82f7ff67719527cd563569e0893.tar.gz gerbolyze-d09cf6ef3b6ea82f7ff67719527cd563569e0893.tar.bz2 gerbolyze-d09cf6ef3b6ea82f7ff67719527cd563569e0893.zip |
svg-flatten: Add 'complete pattern tiles only' switch
This is not part of the SVG spec, but it is useful for generating proto
boards using SVG patterns.
Diffstat (limited to 'svg-flatten/include/geom2d.hpp')
-rw-r--r-- | svg-flatten/include/geom2d.hpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/svg-flatten/include/geom2d.hpp b/svg-flatten/include/geom2d.hpp index 6a52d0b..4fafd80 100644 --- a/svg-flatten/include/geom2d.hpp +++ b/svg-flatten/include/geom2d.hpp @@ -143,17 +143,28 @@ namespace gerbolyze { /* Transform given clipper paths */ void transform_paths(ClipperLib::Paths &paths) { for (auto &p : paths) { - std::transform(p.begin(), p.end(), p.begin(), - [this](ClipperLib::IntPoint p) -> ClipperLib::IntPoint { - d2p out(this->doc2phys(d2p{p.X / clipper_scale, p.Y / clipper_scale})); - return { - (ClipperLib::cInt)round(out[0] * clipper_scale), - (ClipperLib::cInt)round(out[1] * clipper_scale) - }; - }); + transform_clipper_path(p); } } + void transform_clipper_path(ClipperLib::Path &path) { + std::transform(path.begin(), path.end(), path.begin(), + [this](ClipperLib::IntPoint p) -> ClipperLib::IntPoint { + d2p out(this->doc2phys(d2p{p.X / clipper_scale, p.Y / clipper_scale})); + return { + (ClipperLib::cInt)round(out[0] * clipper_scale), + (ClipperLib::cInt)round(out[1] * clipper_scale) + }; + }); + } + + void transform_polygon(Polygon &poly) { + std::transform(poly.begin(), poly.end(), poly.begin(), + [this](d2p p) -> d2p { + return this->doc2phys(d2p{p[0], p[1]}); + }); + } + string dbg_str() { ostringstream os; os << "xform2d< " << setw(5); |