1
0
Fork 0
freesewing/packages/plugin-cutonfold/src/index.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

import meta from "../package.json";
import markers from "./lib/markers";
import style from "./lib/style";
2018-07-23 17:44:52 +00:00
export default {
2018-07-21 15:34:46 +02:00
hooks: {
preRenderSvg: function(next) {
this.attributes.add("freesewing:plugin-cutonfold", meta.version);
this.defs += markers;
this.style += style;
2018-07-21 15:34:46 +02:00
next();
}
},
macros: {
cutonfold: function(next, so) {
2018-07-21 15:34:46 +02:00
let points = this.points;
points.cutonfoldFrom = so.to.shiftTowards(so.from, 30);
points.cutonfoldTo = so.from.shiftTowards(so.to, 30);
points.cutonfoldVia1 = so.to
.shiftTowards(so.from, 50)
.rotate(-90, points.cutonfoldFrom);
points.cutonfoldVia2 = so.from
.shiftTowards(so.to, 50)
.rotate(90, points.cutonfoldTo);
let text = so.grainline ? "cutOnFoldAndGrainline" : "cutOnFold";
this.paths.cutonfold = new this.path()
.move(points.cutonfoldFrom)
.line(points.cutonfoldVia1)
.line(points.cutonfoldVia2)
.line(points.cutonfoldTo)
.attr("class", "cutonfold")
.attr("data-text", text)
.attr("data-text-class", "cutonfold")
.attr("data-text-dy", -2);
2018-07-21 15:34:46 +02:00
next();
}
}
};