From 2cfdf10327356dfd1c657221a0c8db7d778cbede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1n=20D=C3=A9nes?= Date: Sun, 4 Dec 2022 12:22:17 +0100 Subject: [PATCH] Make outline/pcb anchor adjustments more generic --- src/outlines.js | 5 +++-- src/pcbs.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/outlines.js b/src/outlines.js index fe08c04..c1e675e 100644 --- a/src/outlines.js +++ b/src/outlines.js @@ -198,7 +198,8 @@ exports.parse = (config = {}, points = {}, units = {}) => { const original_where = part.where // need to save, so the delete's don't get rid of it below const where = units => filter(original_where, `${name}.where`, points, units, asym) - const adjust = anchor(part.adjust || {}, `${name}.adjust`, points)(units) + const original_adjust = part.adjust // same as above + const adjust = start => anchor(original_adjust || {}, `${name}.adjust`, points, start)(units) const fillet = a.sane(part.fillet || 0, `${name}.fillet`, 'number')(units) expand_shorthand(part, units) const expand = a.sane(part.expand || 0, `${name}.expand`, 'number')(units) @@ -222,7 +223,7 @@ exports.parse = (config = {}, points = {}, units = {}) => { // and then the shape is repeated for all where positions for (const w of where(shape_units)) { - const point = w.clone().shift(adjust.p).rotate(adjust.r, false) + const point = adjust(w.clone()) let [shape, bbox] = shape_maker(point) // point is passed for mirroring metadata only... if (bound) { shape = binding(shape, bbox, point, shape_units) diff --git a/src/pcbs.js b/src/pcbs.js index 05a03e5..cc29176 100644 --- a/src/pcbs.js +++ b/src/pcbs.js @@ -283,12 +283,13 @@ exports.parse = (config, points, outlines, units) => { a.sane(f, name, 'object')() const asym = a.asym(f.asym || 'source', `${name}.asym`) const where = filter(f.where, `${name}.where`, points, units, asym) - const adjust = anchor(f.adjust || {}, `${name}.adjust`, points)(units) + const original_adjust = f.adjust // need to save, so the delete's don't get rid of it below + const adjust = start => anchor(original_adjust || {}, `${name}.adjust`, points, start)(units) delete f.asym delete f.where delete f.adjust for (const w of where) { - const aw = w.clone().shift(adjust.p).rotate(adjust.r, false) + const aw = adjust(w.clone()) footprints.push(footprint_factory(f, name, aw)) } }