2018-07-24 14:06:50 +00:00
|
|
|
import markers from "./lib/markers";
|
2018-08-07 16:43:28 +02:00
|
|
|
import { version, name } from "../package.json";
|
2018-07-21 16:37:18 +02:00
|
|
|
|
2018-07-23 17:44:52 +00:00
|
|
|
export default {
|
2018-08-07 16:43:28 +02:00
|
|
|
name: name,
|
|
|
|
version: version,
|
2018-07-21 15:34:46 +02:00
|
|
|
hooks: {
|
2018-12-08 14:47:12 +01:00
|
|
|
preRender: function(svg) {
|
2018-12-08 17:49:21 +01:00
|
|
|
if (svg.attributes.get("freesewing:plugin-cutonfold") === false) {
|
|
|
|
svg.attributes.set("freesewing:plugin-cutonfold", version);
|
|
|
|
svg.defs += markers;
|
|
|
|
}
|
2018-07-21 15:34:46 +02:00
|
|
|
}
|
2018-07-24 09:10:09 +00:00
|
|
|
},
|
|
|
|
macros: {
|
2018-08-05 13:04:23 +02:00
|
|
|
cutonfold: function(so) {
|
2018-07-21 15:34:46 +02:00
|
|
|
let points = this.points;
|
2019-02-13 14:18:23 +01:00
|
|
|
so = {
|
2019-02-13 14:17:18 +01:00
|
|
|
offset: 50,
|
2019-02-13 14:49:25 +01:00
|
|
|
margin: 5,
|
2019-07-12 13:12:58 +02:00
|
|
|
prefix: "",
|
2019-02-13 14:17:18 +01:00
|
|
|
...so
|
|
|
|
};
|
2019-07-12 13:12:58 +02:00
|
|
|
points["cutonfoldFrom" + so.prefix] = so.to.shiftFractionTowards(
|
2019-02-13 14:49:25 +01:00
|
|
|
so.from,
|
|
|
|
so.margin / 100
|
|
|
|
);
|
2019-07-12 13:12:58 +02:00
|
|
|
points["cutonfoldTo" + so.prefix] = so.from.shiftFractionTowards(
|
|
|
|
so.to,
|
|
|
|
so.margin / 100
|
|
|
|
);
|
|
|
|
points["cutonfoldVia1" + so.prefix] = so.to
|
2019-02-13 14:17:18 +01:00
|
|
|
.shiftTowards(so.from, so.offset)
|
2019-07-12 13:12:58 +02:00
|
|
|
.rotate(-90, points["cutonfoldFrom" + so.prefix]);
|
|
|
|
points["cutonfoldVia2" + so.prefix] = so.from
|
2019-02-13 14:17:18 +01:00
|
|
|
.shiftTowards(so.to, so.offset)
|
2019-07-12 13:12:58 +02:00
|
|
|
.rotate(90, points["cutonfoldTo" + so.prefix]);
|
2018-07-24 14:06:50 +00:00
|
|
|
let text = so.grainline ? "cutOnFoldAndGrainline" : "cutOnFold";
|
2019-07-12 13:12:58 +02:00
|
|
|
this.paths["cutonfold" + so.prefix] = new this.Path()
|
|
|
|
.move(points["cutonfoldFrom" + so.prefix])
|
|
|
|
.line(points["cutonfoldVia1" + so.prefix])
|
|
|
|
.line(points["cutonfoldVia2" + so.prefix])
|
|
|
|
.line(points["cutonfoldTo" + so.prefix])
|
2018-07-25 15:05:40 +00:00
|
|
|
.attr("class", "note")
|
|
|
|
.attr("marker-start", "url(#cutonfoldFrom)")
|
|
|
|
.attr("marker-end", "url(#cutonfoldTo)")
|
2018-07-24 14:06:50 +00:00
|
|
|
.attr("data-text", text)
|
2018-07-25 15:05:40 +00:00
|
|
|
.attr("data-text-class", "center fill-note");
|
2018-07-21 15:34:46 +02:00
|
|
|
}
|
|
|
|
}
|
2018-07-24 09:10:09 +00:00
|
|
|
};
|