2018-08-20 14:00:26 +02:00
|
|
|
import { version, name } from "../package.json";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: name,
|
|
|
|
version: version,
|
|
|
|
hooks: {
|
|
|
|
preRender: function(next) {
|
|
|
|
this.attributes.add("freesewing:plugin-scalebox", version);
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
macros: {
|
|
|
|
scalebox: function(so) {
|
|
|
|
// Boxes
|
2018-08-27 18:10:09 +02:00
|
|
|
this.points.__scaleboxMetricTopLeft = new this.Point(
|
|
|
|
so.at.x - 50,
|
|
|
|
so.at.y - 25
|
|
|
|
);
|
|
|
|
this.points.__scaleboxMetricTopRight = new this.Point(
|
|
|
|
so.at.x + 50,
|
|
|
|
so.at.y - 25
|
|
|
|
);
|
|
|
|
this.points.__scaleboxMetricBottomLeft = new this.Point(
|
|
|
|
so.at.x - 50,
|
|
|
|
so.at.y + 25
|
|
|
|
);
|
|
|
|
this.points.__scaleboxMetricBottomRight = new this.Point(
|
|
|
|
so.at.x + 50,
|
|
|
|
so.at.y + 25
|
|
|
|
);
|
|
|
|
this.points.__scaleboxImperialTopLeft = new this.Point(
|
|
|
|
so.at.x - 50.8,
|
|
|
|
so.at.y - 25.4
|
|
|
|
);
|
|
|
|
this.points.__scaleboxImperialTopRight = new this.Point(
|
|
|
|
so.at.x + 50.8,
|
|
|
|
so.at.y - 25.4
|
|
|
|
);
|
|
|
|
this.points.__scaleboxImperialBottomLeft = new this.Point(
|
|
|
|
so.at.x - 50.8,
|
|
|
|
so.at.y + 25.4
|
|
|
|
);
|
|
|
|
this.points.__scaleboxImperialBottomRight = new this.Point(
|
|
|
|
so.at.x + 50.8,
|
|
|
|
so.at.y + 25.4
|
|
|
|
);
|
2018-08-20 14:00:26 +02:00
|
|
|
this.paths.__scaleboxImperial = new this.Path()
|
|
|
|
.move(this.points.__scaleboxImperialTopLeft)
|
|
|
|
.line(this.points.__scaleboxImperialBottomLeft)
|
|
|
|
.line(this.points.__scaleboxImperialBottomRight)
|
|
|
|
.line(this.points.__scaleboxImperialTopRight)
|
|
|
|
.close()
|
2018-08-27 18:10:09 +02:00
|
|
|
.attr("style", "fill: #000; stroke: none;");
|
2018-08-20 14:00:26 +02:00
|
|
|
this.paths.__scaleboxMetric = new this.Path()
|
|
|
|
.move(this.points.__scaleboxMetricTopLeft)
|
|
|
|
.line(this.points.__scaleboxMetricBottomLeft)
|
|
|
|
.line(this.points.__scaleboxMetricBottomRight)
|
|
|
|
.line(this.points.__scaleboxMetricTopRight)
|
|
|
|
.close()
|
2018-08-27 18:10:09 +02:00
|
|
|
.attr("style", "fill: #FFF; stroke: none;");
|
2018-08-20 14:00:26 +02:00
|
|
|
// Lead
|
|
|
|
this.points.__scaleboxLead = new this.Point(so.at.x - 45, so.at.y - 15)
|
2018-08-27 18:10:09 +02:00
|
|
|
.attr("data-text", so.lead || "freesewing")
|
|
|
|
.attr("data-text-class", "text-sm");
|
2018-08-20 14:00:26 +02:00
|
|
|
// Title
|
2018-08-27 18:10:09 +02:00
|
|
|
this.points.__scaleboxTitle = this.points.__scaleboxLead
|
|
|
|
.shift(-90, 10)
|
2018-08-20 14:00:26 +02:00
|
|
|
.attr(
|
|
|
|
"data-text",
|
2018-08-27 18:10:09 +02:00
|
|
|
so.title ||
|
|
|
|
this.context.config.name + " v" + this.context.config.version
|
2018-08-20 14:00:26 +02:00
|
|
|
)
|
2018-08-27 18:10:09 +02:00
|
|
|
.attr("data-text-class", "text-lg");
|
2018-08-20 14:00:26 +02:00
|
|
|
// Text
|
|
|
|
this.points.__scaleboxText = this.points.__scaleboxTitle.shift(-90, 8);
|
2018-08-27 18:10:09 +02:00
|
|
|
if (typeof so.text === "string") {
|
|
|
|
this.points.__scaleboxText.attr("data-text", so.text);
|
2018-08-20 14:00:26 +02:00
|
|
|
} else {
|
|
|
|
this.points.__scaleboxText
|
2018-08-27 18:10:09 +02:00
|
|
|
.attr("data-text", "freesewingIsMadeByJoostDeCockAndContributors")
|
|
|
|
.attr("data-text", "\n")
|
|
|
|
.attr("data-text", "withTheFinancialSupportOfOurPatrons");
|
|
|
|
this.points.__scaleboxLink = this.points.__scaleboxText
|
|
|
|
.shift(-90, 8)
|
|
|
|
.attr("data-text", "freesewing.org/patrons/join")
|
|
|
|
.attr("data-text-class", "text-xs fill-note");
|
2018-08-20 14:00:26 +02:00
|
|
|
}
|
|
|
|
this.points.__scaleboxText
|
2018-08-27 18:10:09 +02:00
|
|
|
.attr("data-text-class", "text-xs")
|
|
|
|
.attr("data-text-lineheight", 4);
|
2018-08-20 14:00:26 +02:00
|
|
|
// Instructions
|
|
|
|
this.points.__scaleboxMetric = new this.Point(so.at.x, so.at.y + 20)
|
2018-08-27 18:10:09 +02:00
|
|
|
.attr("data-text", "theWhiteInsideOfThisBoxShouldMeasure")
|
|
|
|
.attr("data-text", "10cm x 5cm")
|
|
|
|
.attr("data-text-class", "text-xs center");
|
2018-08-20 14:00:26 +02:00
|
|
|
this.points.__scaleboxImperial = new this.Point(so.at.x, so.at.y + 24)
|
2018-08-27 18:10:09 +02:00
|
|
|
.attr("data-text", "theBlackOutsideOfThisBoxShouldMeasure")
|
|
|
|
.attr("data-text", '4" x 2"')
|
|
|
|
.attr("data-text-class", "text-xs center ");
|
2018-08-20 14:00:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|