aboutsummaryrefslogtreecommitdiff
path: root/svg-flatten/src/out_scaler.cpp
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-06-20 16:19:53 +0200
committerjaseg <git@jaseg.de>2022-06-20 16:19:53 +0200
commit9e9cc2bc019f0e67720ad5da16315e7cd6781e78 (patch)
treedd0531eef230fa8042143019db669e2841170f8a /svg-flatten/src/out_scaler.cpp
parent0e1c8507bbda04f131ae0733e38b5f18996531b1 (diff)
downloadgerbolyze-9e9cc2bc019f0e67720ad5da16315e7cd6781e78.tar.gz
gerbolyze-9e9cc2bc019f0e67720ad5da16315e7cd6781e78.tar.bz2
gerbolyze-9e9cc2bc019f0e67720ad5da16315e7cd6781e78.zip
svg-flatten: add export of patterns via aperture macros
Diffstat (limited to 'svg-flatten/src/out_scaler.cpp')
-rw-r--r--svg-flatten/src/out_scaler.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/svg-flatten/src/out_scaler.cpp b/svg-flatten/src/out_scaler.cpp
index 0320d69..fb54145 100644
--- a/svg-flatten/src/out_scaler.cpp
+++ b/svg-flatten/src/out_scaler.cpp
@@ -69,3 +69,26 @@ PolygonScaler &PolygonScaler::operator<<(const DrillToken &tok) {
m_sink << DrillToken(new_center);
return *this;
}
+
+PolygonScaler &PolygonScaler::operator<<(const FlashToken &tok) {
+ d2p new_offset = { tok.m_offset[0] * m_scale, tok.m_offset[1] * m_scale};
+ m_sink << FlashToken(new_offset);
+ return *this;
+}
+
+PolygonScaler &PolygonScaler::operator<<(const PatternToken &tok) {
+ vector<pair<Polygon, GerberPolarityToken>> new_polys;
+ for (size_t i=0; i<tok.m_polys.size(); i++) {
+ Polygon poly(tok.m_polys[i].first.size());
+ for (size_t j=0; j<poly.size(); j++) {
+ d2p new_point = tok.m_polys[i].first[j];
+ new_point[0] *= m_scale;
+ new_point[1] *= m_scale;
+ poly[j] = new_point;
+ }
+ new_polys.emplace_back(pair<Polygon, GerberPolarityToken>{poly, tok.m_polys[i].second});
+ }
+ m_sink << PatternToken(new_polys);
+ return *this;
+}
+