2018-08-10 18:48:21 +02:00
|
|
|
import markers from "./markers";
|
2018-08-10 18:42:20 +02:00
|
|
|
import { version, name } from "../package.json";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: name,
|
|
|
|
version: version,
|
|
|
|
hooks: {
|
2018-12-08 15:01:14 +01:00
|
|
|
preRender: function(svg) {
|
2018-12-08 17:51:54 +01:00
|
|
|
if(svg.attributes.get('freesewing:plugin-grainline') === false) {
|
|
|
|
svg.attributes.set('freesewing:plugin-grainline', version);
|
|
|
|
svg.defs += markers;
|
|
|
|
}
|
2018-08-10 18:42:20 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
macros: {
|
|
|
|
grainline: function(so) {
|
|
|
|
let points = this.points;
|
|
|
|
points.grainlineFrom = so.from.shiftFractionTowards(so.to, 0.05);
|
|
|
|
points.grainlineTo = so.to.shiftFractionTowards(so.from, 0.05);
|
|
|
|
this.paths.grainline = new this.Path()
|
|
|
|
.move(points.grainlineFrom)
|
|
|
|
.line(points.grainlineTo)
|
|
|
|
.attr("class", "note")
|
|
|
|
.attr("marker-start", "url(#grainlineFrom)")
|
|
|
|
.attr("marker-end", "url(#grainlineTo)")
|
|
|
|
.attr("data-text", "grainline")
|
|
|
|
.attr("data-text-class", "center fill-note");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|