2018-07-26 07:18:21 +00:00
|
|
|
import style from "./lib/style";
|
2018-08-07 16:50:10 +02:00
|
|
|
import { version, name } from "../package.json";
|
2018-07-22 18:54:58 +02:00
|
|
|
|
2018-07-26 07:18:21 +00:00
|
|
|
export default {
|
2018-08-07 16:50:10 +02:00
|
|
|
name: name,
|
|
|
|
version: version,
|
2018-07-22 18:54:58 +02:00
|
|
|
hooks: {
|
2018-12-08 15:11:00 +01:00
|
|
|
preRender: function(svg) {
|
2018-12-08 17:44:30 +01:00
|
|
|
if (svg.attributes.get("freesewing:plugin-title") === false) {
|
|
|
|
svg.attributes.set("freesewing:plugin-title", version);
|
|
|
|
svg.style += style;
|
|
|
|
}
|
2018-07-22 18:54:58 +02:00
|
|
|
}
|
2018-07-26 07:18:21 +00:00
|
|
|
},
|
|
|
|
macros: {
|
2018-08-05 13:09:09 +02:00
|
|
|
title: function(so) {
|
2018-12-22 17:20:04 +01:00
|
|
|
const transform = function(anchor) {
|
|
|
|
let cx = anchor.x - so.scale * anchor.x;
|
|
|
|
let cy = anchor.y - so.scale * anchor.y;
|
|
|
|
|
|
|
|
return `matrix(${so.scale}, 0, 0, ${so.scale}, ${cx}, ${cy}) rotate(${
|
|
|
|
so.rotation
|
|
|
|
} ${anchor.x} ${anchor.y})`;
|
|
|
|
};
|
|
|
|
let defaults = {
|
|
|
|
scale: 1,
|
|
|
|
rotation: 0
|
|
|
|
};
|
|
|
|
so = { ...defaults, ...so };
|
2018-08-07 16:50:10 +02:00
|
|
|
let overwrite = true;
|
|
|
|
if (so.append) overwrite = false;
|
2018-09-10 12:07:36 +02:00
|
|
|
let prefix = "";
|
|
|
|
if (so.prefix) prefix = so.prefix;
|
|
|
|
this.points[`_${prefix}_titleNr`] = so.at
|
2018-12-08 15:12:00 +01:00
|
|
|
.clone()
|
2018-08-07 16:50:10 +02:00
|
|
|
.attr("data-text", so.nr, overwrite)
|
2018-12-22 17:20:04 +01:00
|
|
|
.attr("data-text-class", "title-nr note fill-note")
|
2019-05-10 13:14:31 +02:00
|
|
|
.attr("data-text-transform", transform(so.at));
|
2018-09-10 12:07:36 +02:00
|
|
|
let shift = 10;
|
2018-12-08 15:12:00 +01:00
|
|
|
if (so.title) {
|
2018-09-10 12:07:36 +02:00
|
|
|
this.points[`_${prefix}_titleName`] = so.at
|
2018-12-22 17:20:04 +01:00
|
|
|
.shift(-90 - so.rotation, 13 * so.scale)
|
2018-09-10 12:07:36 +02:00
|
|
|
.attr("data-text", so.title)
|
2018-12-22 17:20:04 +01:00
|
|
|
.attr("data-text-class", "title-name")
|
|
|
|
.attr(
|
|
|
|
"data-text-transform",
|
|
|
|
transform(so.at.shift(-90 - so.rotation, 13 * so.scale))
|
|
|
|
);
|
2018-09-10 12:07:36 +02:00
|
|
|
shift += 10;
|
|
|
|
}
|
|
|
|
this.points[`_${prefix}_titlePattern`] = so.at
|
2018-12-22 17:20:04 +01:00
|
|
|
.shift(-90 - so.rotation, shift * so.scale)
|
2018-09-05 15:51:48 +02:00
|
|
|
.attr("data-text", this.context.config.name)
|
|
|
|
.attr("data-text", "v" + this.context.config.version)
|
2018-12-22 17:20:04 +01:00
|
|
|
.attr("data-text-class", "title-pattern fill-note")
|
|
|
|
.attr(
|
|
|
|
"data-text-transform",
|
|
|
|
transform(so.at.shift(-90 - so.rotation, shift * so.scale))
|
|
|
|
);
|
2018-07-22 18:54:58 +02:00
|
|
|
}
|
|
|
|
}
|
2018-07-26 07:18:21 +00:00
|
|
|
};
|