2022-08-28 16:49:21 +02:00
|
|
|
// 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'
|
2020-09-25 15:47:28 -07:00
|
|
|
|
2022-08-28 16:49:21 +02:00
|
|
|
// crossbox macro
|
2020-09-26 17:11:31 -07:00
|
|
|
const crossBox = {
|
2022-06-14 13:02:28 +02:00
|
|
|
name: 'crossbox',
|
2022-08-28 16:49:21 +02:00
|
|
|
version,
|
2020-09-26 17:11:31 -07:00
|
|
|
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')
|
|
|
|
}
|
2021-04-24 10:16:31 +02:00
|
|
|
},
|
|
|
|
},
|
2020-09-26 17:11:31 -07:00
|
|
|
}
|
|
|
|
|
2020-09-25 15:47:28 -07:00
|
|
|
|
2022-08-28 16:49:21 +02:00
|
|
|
// Setup our new design
|
|
|
|
const Albert = new Design({
|
|
|
|
name,
|
|
|
|
version,
|
|
|
|
parts: [ front, pocket, strap ],
|
|
|
|
plugins: [ pluginBundle, crossBox ]
|
|
|
|
})
|
2020-09-25 15:47:28 -07:00
|
|
|
|
2022-06-14 13:02:28 +02:00
|
|
|
// Named exports
|
2022-08-28 16:49:21 +02:00
|
|
|
export { front, pocket, strap, Albert }
|
|
|
|
|
|
|
|
|
2022-06-14 13:02:28 +02:00
|
|
|
|