feat(plugin-title): Added support for cutting instructions. Closes #500
This commit is contained in:
parent
ef21065e4f
commit
1519f12920
1 changed files with 19 additions and 3 deletions
|
@ -5,7 +5,7 @@ export default {
|
|||
name: name,
|
||||
version: version,
|
||||
hooks: {
|
||||
preRender: function(svg) {
|
||||
preRender: function (svg) {
|
||||
if (svg.attributes.get('freesewing:plugin-title') === false) {
|
||||
svg.attributes.set('freesewing:plugin-title', version)
|
||||
svg.style += style
|
||||
|
@ -13,8 +13,8 @@ export default {
|
|||
}
|
||||
},
|
||||
macros: {
|
||||
title: function(so) {
|
||||
const transform = function(anchor) {
|
||||
title: function (so) {
|
||||
const transform = function (anchor) {
|
||||
let cx = anchor.x - so.scale * anchor.x
|
||||
let cy = anchor.y - so.scale * anchor.y
|
||||
|
||||
|
@ -57,6 +57,22 @@ export default {
|
|||
.attr('data-text-class', 'title-pattern')
|
||||
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
|
||||
}
|
||||
if (this.context.config.cut && this.context.config.cut[this.name]) {
|
||||
shift += 8
|
||||
let cid = `_${prefix}_titleCut`
|
||||
let cut = this.context.config.cut[this.name]
|
||||
this.points[cid] = so.at
|
||||
.shift(-90 - so.rotation, shift * so.scale)
|
||||
.attr('data-text', 'cut')
|
||||
.attr('data-text-class', 'title-pattern')
|
||||
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
|
||||
if (typeof cut === 'number') this.points[cid].attr('data-text', ` ${cut}x`)
|
||||
else if (Array.isArray(cut)) {
|
||||
cut = Array.from(cut) // Don't change the original array
|
||||
this.points[cid].attr('data-text', ` ${cut.shift()}x`)
|
||||
for (const txt of cut) this.points[cid].attr('data-text', txt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue