// FreeSewing Design constructor import { Design } from '@freesewing/core' // FreeSewing Plugins import { pluginBundle } from '@freesewing/plugin-bundle' // Design parts import { front } from './front.mjs' import { pocket } from './pocket.mjs' import { strap } from './strap.mjs' // Get name & version from package.json import { name, version } from '../package.json' // crossbox macro const crossBox = { name: 'crossbox', version, macros: { crossBox: function (so) { let id = this.getId() let shiftFraction = 0.1 this.points[id + '_boxTopLeft'] = so.from.copy() this.points[id + '_boxBottomRight'] = so.to.copy() this.points[id + '_boxTopRight'] = new this.Point(so.to.x, so.from.y) this.points[id + '_boxBottomLeft'] = new this.Point(so.from.x, so.to.y) this.points[id + '_topCrossTL'] = this.points[id + '_boxTopLeft'].shiftFractionTowards( this.points[id + '_boxBottomRight'], shiftFraction ) this.points[id + '_topCrossTR'] = this.points[id + '_boxTopRight'].shiftFractionTowards( this.points[id + '_boxBottomLeft'], shiftFraction ) this.points[id + '_topCrossBL'] = this.points[id + '_boxBottomLeft'].shiftFractionTowards( this.points[id + '_boxTopRight'], shiftFraction ) this.points[id + '_topCrossBR'] = this.points[id + '_boxBottomRight'].shiftFractionTowards( this.points[id + '_boxTopLeft'], shiftFraction ) this.paths[id + 'crossBox'] = new this.Path() .move(this.points[id + '_boxTopLeft']) .line(this.points[id + '_boxTopRight']) .line(this.points[id + '_boxBottomRight']) .line(this.points[id + '_boxBottomLeft']) .line(this.points[id + '_boxTopLeft']) .close() .attr('class', 'lining dotted stroke-sm') this.paths[id + '_topCross'] = new this.Path() .move(this.points[id + '_topCrossTL']) .line(this.points[id + '_topCrossBR']) .line(this.points[id + '_topCrossTR']) .line(this.points[id + '_topCrossBL']) .line(this.points[id + '_topCrossTL']) .line(this.points[id + '_topCrossTR']) .move(this.points[id + '_topCrossBR']) .line(this.points[id + '_topCrossBL']) .attr('class', 'lining dotted stroke-sm') if (typeof so.text === 'string') { this.points.textAnchor = this.points[id + '_boxTopLeft'] .shiftFractionTowards(this.points[id + '_boxBottomRight'], 0.5) .attr('data-text', so.text) .attr('data-text-class', 'center') } }, }, } // Setup our new design const Albert = new Design({ name, version, parts: [ front, pocket, strap ], plugins: [ pluginBundle, crossBox ] }) // Named exports export { front, pocket, strap, Albert }