@freesewing/plugin-dimension
Version:
A FreeSewing plugin to add dimensions to your (paperless) pattern
16 lines (15 loc) • 4.3 kB
JavaScript
/**
* @freesewing/plugin-dimension | v2.22.2
* A FreeSewing plugin to add dimensions to your (paperless) pattern
* (c) 2022 Joost De Cock <joost@joost.at> (https://github.com/joostdecock)
* @license MIT
*/
var f=`
<marker orient="auto" refY="4.0" refX="0.0" id="dimensionFrom" style="overflow:visible;" markerWidth="12" markerHeight="8">
<path class="mark fill-mark" d="M 0,4 L 12,0 C 10,2 10,6 12,8 z" />
</marker>
<marker orient="auto" refY="4.0" refX="12.0" id="dimensionTo" style="overflow:visible;" markerWidth="12" markerHeight="8">
<path class="mark fill-mark" d="M 12,4 L 0,0 C 2,2 2,6 0,8 z" />
</marker>
`;var a={name:"@freesewing/plugin-dimension",version:"2.22.2",description:"A FreeSewing plugin to add dimensions to your (paperless) pattern",author:"Joost De Cock <joost@joost.at> (https://github.com/joostdecock)",homepage:"https://freesewing.org/",repository:"github:freesewing/freesewing",license:"MIT",bugs:{url:"https://github.com/freesewing/freesewing/issues"},funding:{type:"individual",url:"https://freesewing.org/patrons/join"},keywords:["freesewing","plugin","sewing pattern","sewing","design","parametric design","made to measure","diy","fashion"],main:"dist/index.js",module:"dist/index.mjs",scripts:{build:"node build.js",clean:"rimraf dist",mbuild:"NO_MINIFY=1 node build.js",symlink:"mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -",test:"npx mocha tests/*.test.mjs",vbuild:"VERBOSE=1 node build.js",lab:"cd ../../sites/lab && yarn start",tips:"node ../../scripts/help.mjs",prettier:"npx prettier --write 'src/*.js' 'tests/*.mjs'",testci:"npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js",cibuild_step1:"node build.js"},peerDependencies:{"@freesewing/core":"^2.22.2"},dependencies:{},devDependencies:{mocha:"^10.0.0",chai:"^4.2.0"},files:["dist/*","README.md"],publishConfig:{access:"public",tag:"latest"},engines:{node:">=14.0.0",npm:">=6"}};var n="__paperless";function h(e,t,i,r){let s=new r.Path().move(e).line(t).attr("class","mark").attr("data-text",i.text||r.units(e.dist(t))).attr("data-text-class","fill-mark center");return i.noStartMarker||s.attributes.set("marker-start","url(#dimensionFrom)"),i.noEndMarker||s.attributes.set("marker-end","url(#dimensionTo)"),s}function d(e,t,i,r){e.paths[r]=new e.Path().move(t).line(i).attr("class","mark dotted")}function m(e,t,i,r){let s;return typeof e.y>"u"||e[t].y===e.y?s=e[t]:(s=new i.Point(e[t].x,e.y),d(i,e[t],s,r)),s}function p(e,t,i,r){let s;return typeof e.x>"u"||e[t].x===e.x?s=e[t]:(s=new i.Point(e.x,e[t].y),d(i,e[t],s,r)),s}function u(e,t,i,r){let s,l,o;return t==="from"?(l=1,o="to"):(l=-1,o="from"),typeof e.d>"u"?s=e[t]:(s=e[t].shiftTowards(e[o],e.d).rotate(90*l,e[t]),d(i,e[t],s,r)),s}var _={name:a.name,version:a.version,hooks:{preRender:e=>{e.attributes.get("freesewing:plugin-dimension")===!1&&(e.attributes.set("freesewing:plugin-dimension",a.version),e.defs+=f)}},macros:{hd:function(e){let t=e.id||this.getId(n);this.paths[t]=h(m(e,"from",this,t+"_ls"),m(e,"to",this,t+"_le"),e,this)},vd:function(e){let t=e.id||this.getId(n);this.paths[t]=h(p(e,"from",this,t+"_ls"),p(e,"to",this,t+"_le"),e,this)},ld:function(e){let t=e.id||this.getId(n);this.paths[t]=h(u(e,"from",this,t+"_ls"),u(e,"to",this,t+"_le"),e,this)},pd:function(e){let t=e.id||this.getId(n);typeof e.d>"u"&&(e.d=10*this.context.settings.scale);let i=e.path.offset(e.d).attr("class","mark").attr("data-text",e.text||this.units(e.path.length())).attr("data-text-class","fill-mark center");e.noStartMarker||i.attributes.set("marker-start","url(#dimensionFrom)"),e.noEndMarker||i.attributes.set("marker-end","url(#dimensionTo)"),this.paths[t]=i,d(this,e.path.start(),i.start(),t+"_ls"),d(this,e.path.end(),i.end(),t+"_le")},rmd:function(e){if(this.paths[e.id]&&delete this.paths[e.id],this.paths[`${e.id}_ls`]&&delete this.paths[`${e.id}_ls`],this.paths[`${e.id}_le`]&&delete this.paths[`${e.id}_le`],Array.isArray(e.ids))for(let t of e.ids)this.paths[t]&&delete this.paths[t],this.paths[`${t}_ls`]&&delete this.paths[`${t}_ls`],this.paths[`${t}_le`]&&delete this.paths[`${t}_le`]},rmad:function(e){for(let t of["paths","points"])for(let i in this[t])i.slice(0,n.length)===n&&delete this[t][i]}}};export{_ as default};
//# sourceMappingURL=index.mjs.map