diff --git a/roadmap.md b/roadmap.md index aa7d531..9423c65 100644 --- a/roadmap.md +++ b/roadmap.md @@ -6,7 +6,6 @@ ### Major -- Gut standalone 3d output, only different scripts for different integrations - Key-level access to full anchors - this could provide extra variables `padding`, `spread`, `splay` for custom layout purposes - make row anchors cumulative, too (like columns), so fingers arcs and other edits can happen @@ -27,7 +26,6 @@ - Include raw kicad footprint integrations - pull torik's script to be able to convert raw kicad footprints into positionable ergogen ones - have a `dummy` footprint which can just be updated from schematic -- Shift/rotate/scale for outline elements before layout - Allow footprints to publish outlines - Make these usable in the `outlines` section through a new `what` - 3D orient for cases diff --git a/src/outlines.js b/src/outlines.js index ed1061f..d2e417f 100644 --- a/src/outlines.js +++ b/src/outlines.js @@ -128,18 +128,23 @@ const polygon = (config, name, points, outlines, units) => { const outline = (config, name, points, outlines, units) => { // prepare params - a.unexpected(config, `${name}`, ['name', 'fillet', 'expand', 'origin']) + a.unexpected(config, `${name}`, ['name', 'fillet', 'expand', 'origin', 'scale']) a.assert(outlines[config.name], `Field "${name}.name" does not name an existing outline!`) const fillet = a.sane(config.fillet || 0, `${name}.fillet`, 'number')(units) const expand = a.sane(config.expand || 0, `${name}.expand`, 'number')(units) const joints = a.in(a.sane(config.joints || 0, `${name}.joints`, 'number')(units), `${name}.joints`, [0, 1, 2]) const origin = anchor(config.origin || {}, `${name}.origin`, points)(units) + const scale = a.sane(config.scale || 1, `${name}.scale`, 'number')(units) // return shape function and its units return [(point, bound) => { let o = u.deepcopy(outlines[config.name]) o = origin.unposition(o) + if (scale !== 1) { + o = m.model.scale(o, scale) + } + if (fillet) { for (const [index, chain] of m.model.findChains(o).entries()) { o.models[`fillet_${index}`] = m.chain.fillet(chain, fillet) diff --git a/test/outlines/fillet.yaml b/test/outlines/outlines.yaml similarity index 78% rename from test/outlines/fillet.yaml rename to test/outlines/outlines.yaml index 5dc5e85..351fff7 100644 --- a/test/outlines/fillet.yaml +++ b/test/outlines/outlines.yaml @@ -19,4 +19,8 @@ outlines: fillet: - what: outline name: base - fillet: 2 \ No newline at end of file + fillet: 2 + scale: + - what: outline + name: fillet + scale: 0.5 \ No newline at end of file diff --git a/test/outlines/fillet___outlines_fillet_dxf.dxf b/test/outlines/outlines___outlines_fillet_dxf.dxf similarity index 100% rename from test/outlines/fillet___outlines_fillet_dxf.dxf rename to test/outlines/outlines___outlines_fillet_dxf.dxf diff --git a/test/outlines/outlines___outlines_scale_dxf.dxf b/test/outlines/outlines___outlines_scale_dxf.dxf new file mode 100644 index 0000000..1cd04be --- /dev/null +++ b/test/outlines/outlines___outlines_scale_dxf.dxf @@ -0,0 +1,258 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +4.3 +20 +-3.3 +11 +4.3 +21 +11.8 +0 +LINE +8 +0 +10 +-3.3 +20 +-4.3 +11 +3.3 +21 +-4.3 +0 +LINE +8 +0 +10 +-4.3 +20 +-3.3 +11 +-4.3 +21 +11.8 +0 +LINE +8 +0 +10 +-3.3 +20 +12.8 +11 +3.3 +21 +12.8 +0 +LINE +8 +0 +10 +13.8 +20 +-3.3 +11 +13.8 +21 +11.8 +0 +LINE +8 +0 +10 +6.2 +20 +-4.3 +11 +12.8 +21 +-4.3 +0 +LINE +8 +0 +10 +5.2 +20 +-3.3 +11 +5.2 +21 +11.8 +0 +LINE +8 +0 +10 +6.2 +20 +12.8 +11 +12.8 +21 +12.8 +0 +ARC +8 +0 +10 +3.3 +20 +11.8 +40 +1 +50 +0 +51 +90 +0 +ARC +8 +0 +10 +-3.3 +20 +11.8 +40 +1 +50 +90 +51 +180 +0 +ARC +8 +0 +10 +-3.3 +20 +-3.3 +40 +1 +50 +180 +51 +270 +0 +ARC +8 +0 +10 +3.3 +20 +-3.3 +40 +1 +50 +270 +51 +0 +0 +ARC +8 +0 +10 +12.8 +20 +11.8 +40 +1 +50 +0 +51 +90 +0 +ARC +8 +0 +10 +6.2 +20 +11.8 +40 +1 +50 +90 +51 +180 +0 +ARC +8 +0 +10 +6.2 +20 +-3.3 +40 +1 +50 +180 +51 +270 +0 +ARC +8 +0 +10 +12.8 +20 +-3.3 +40 +1 +50 +270 +51 +0 +0 +ENDSEC +0 +EOF \ No newline at end of file