// Export defs export const grainlineDefs = [ { name: 'grainlineFrom', def: ` `, }, { name: 'grainlineTo', def: ` `, }, ] const dflts = { text: 'grainline' } // Export macros export const grainlineMacros = { grainline: function (so = {}, { points, paths, Path, complete, store }) { if (so === false) { delete points.grainlineFrom delete points.grainlineTo delete paths.grainline if (store.cutlist?.setGrain) store.cutlist.setGrain(90) // Restoring default return true } so = { ...dflts, ...so, } // store in cutlist store.cutlist.setGrain(so.from.angle(so.to)) if (complete) { points.grainlineFrom = so.from.shiftFractionTowards(so.to, 0.05) points.grainlineTo = so.to.shiftFractionTowards(so.from, 0.05) paths.grainline = new Path() .move(points.grainlineFrom) .line(points.grainlineTo) .attr('class', 'note') .attr('marker-start', 'url(#grainlineFrom)') .attr('marker-end', 'url(#grainlineTo)') .attr('data-text', so.text) .attr('data-text-class', 'center fill-note') } }, }