1
0
Fork 0

Merge branch 'plugin-cutonfold' into cutlist

This commit is contained in:
joostdecock 2022-07-31 13:59:37 +02:00
commit 792021b60f

View file

@ -14,40 +14,45 @@ export default {
}, },
macros: { macros: {
cutonfold: function (so) { cutonfold: function (so) {
const { points, complete } = this.shorthand()
if (so === false) { if (so === false) {
delete this.points.cutonfoldFrom delete this.points.cutonfoldFrom
delete this.points.cutonfoldTo delete this.points.cutonfoldTo
delete this.points.cutonfoldVia1 delete this.points.cutonfoldVia1
delete this.points.cutonfoldVia2 delete this.points.cutonfoldVia2
delete this.paths.cutonfold delete this.paths.cutonfold
this.setCutOnFold(false) // Restore default
return true return true
} }
const points = this.points
so = { so = {
offset: 15, offset: 15,
margin: 5, margin: 5,
prefix: '', prefix: '',
...so, ...so,
} }
points['cutonfoldFrom' + so.prefix] = so.from.shiftFractionTowards(so.to, so.margin / 100) this.setCutOnFold(so.from, so.to)
points['cutonfoldTo' + so.prefix] = so.to.shiftFractionTowards(so.from, so.margin / 100) if (so.grainline) this.setGrain(so.from.angle(so.to))
points['cutonfoldVia1' + so.prefix] = points['cutonfoldFrom' + so.prefix] if (complete) {
.shiftTowards(so.from, so.offset * this.context.settings.scale) points['cutonfoldFrom' + so.prefix] = so.from.shiftFractionTowards(so.to, so.margin / 100)
.rotate(-90, points['cutonfoldFrom' + so.prefix]) points['cutonfoldTo' + so.prefix] = so.to.shiftFractionTowards(so.from, so.margin / 100)
points['cutonfoldVia2' + so.prefix] = points['cutonfoldTo' + so.prefix] points['cutonfoldVia1' + so.prefix] = points['cutonfoldFrom' + so.prefix]
.shiftTowards(so.to, so.offset * this.context.settings.scale) .shiftTowards(so.from, so.offset * this.context.settings.scale)
.rotate(90, points['cutonfoldTo' + so.prefix]) .rotate(-90, points['cutonfoldFrom' + so.prefix])
const text = so.grainline ? 'cutOnFoldAndGrainline' : 'cutOnFold' points['cutonfoldVia2' + so.prefix] = points['cutonfoldTo' + so.prefix]
this.paths['cutonfold' + so.prefix] = new this.Path() .shiftTowards(so.to, so.offset * this.context.settings.scale)
.move(points['cutonfoldFrom' + so.prefix]) .rotate(90, points['cutonfoldTo' + so.prefix])
.line(points['cutonfoldVia1' + so.prefix]) const text = so.grainline ? 'cutOnFoldAndGrainline' : 'cutOnFold'
.line(points['cutonfoldVia2' + so.prefix]) this.paths['cutonfold' + so.prefix] = new this.Path()
.line(points['cutonfoldTo' + so.prefix]) .move(points['cutonfoldFrom' + so.prefix])
.attr('class', 'note') .line(points['cutonfoldVia1' + so.prefix])
.attr('marker-start', 'url(#cutonfoldFrom)') .line(points['cutonfoldVia2' + so.prefix])
.attr('marker-end', 'url(#cutonfoldTo)') .line(points['cutonfoldTo' + so.prefix])
.attr('data-text', text) .attr('class', 'note')
.attr('data-text-class', 'center fill-note') .attr('marker-start', 'url(#cutonfoldFrom)')
.attr('marker-end', 'url(#cutonfoldTo)')
.attr('data-text', text)
.attr('data-text-class', 'center fill-note')
}
}, },
}, },
} }