chore(plugin-scalebox): Make sure scalebox and miniscale can coexist
Also took my name of the patterns
This commit is contained in:
parent
650b7931ab
commit
eccf8f58b7
2 changed files with 47 additions and 53 deletions
|
@ -2,52 +2,48 @@ export default function(so) {
|
|||
// Passing `false` will remove the miniscale
|
||||
if (so === false) {
|
||||
for (let id of [
|
||||
'__scaleboxMetricTopLeft',
|
||||
'__scaleboxMetricTopRight',
|
||||
'__scaleboxMetricBottomRight',
|
||||
'__scaleboxMetricBottomLeft',
|
||||
'__scaleboxImperialTopLeft',
|
||||
'__scaleboxImperialTopRight',
|
||||
'__scaleboxImperialBottomRight',
|
||||
'__scaleboxImperialBottomLeft',
|
||||
'__scaleboxLead',
|
||||
'__scaleboxTitle',
|
||||
'__scaleboxText',
|
||||
'__scaleboxLink',
|
||||
'__scaleboxMetric',
|
||||
'__scaleboxImperial'
|
||||
'__miniscaleMetricTopLeft',
|
||||
'__miniscaleMetricTopRight',
|
||||
'__miniscaleMetricBottomRight',
|
||||
'__miniscaleMetricBottomLeft',
|
||||
'__miniscaleImperialTopLeft',
|
||||
'__miniscaleImperialTopRight',
|
||||
'__miniscaleImperialBottomRight',
|
||||
'__miniscaleImperialBottomLeft',
|
||||
'__miniscaleMetric',
|
||||
'__miniscaleImperial'
|
||||
])
|
||||
delete this.points[id]
|
||||
for (let id of ['__scaleboxMetric', '__scaleboxImperial']) delete this.paths[id]
|
||||
for (let id of ['__miniscaleMetric', '__miniscaleImperial']) delete this.paths[id]
|
||||
return true
|
||||
}
|
||||
const m = 12.5
|
||||
const i = 12.7
|
||||
// Box points
|
||||
this.points.__scaleboxMetricTopLeft = new this.Point(so.at.x - m, so.at.y - m)
|
||||
this.points.__scaleboxMetricTopRight = new this.Point(so.at.x + m, so.at.y - m)
|
||||
this.points.__scaleboxMetricBottomLeft = new this.Point(so.at.x - m, so.at.y + m)
|
||||
this.points.__scaleboxMetricBottomRight = new this.Point(so.at.x + m, so.at.y + m)
|
||||
this.points.__scaleboxImperialTopLeft = new this.Point(so.at.x - i, so.at.y - i)
|
||||
this.points.__scaleboxImperialTopRight = new this.Point(so.at.x + i, so.at.y - i)
|
||||
this.points.__scaleboxImperialBottomLeft = new this.Point(so.at.x - i, so.at.y + i)
|
||||
this.points.__scaleboxImperialBottomRight = new this.Point(so.at.x + i, so.at.y + i)
|
||||
this.points.__miniscaleMetricTopLeft = new this.Point(so.at.x - m, so.at.y - m)
|
||||
this.points.__miniscaleMetricTopRight = new this.Point(so.at.x + m, so.at.y - m)
|
||||
this.points.__miniscaleMetricBottomLeft = new this.Point(so.at.x - m, so.at.y + m)
|
||||
this.points.__miniscaleMetricBottomRight = new this.Point(so.at.x + m, so.at.y + m)
|
||||
this.points.__miniscaleImperialTopLeft = new this.Point(so.at.x - i, so.at.y - i)
|
||||
this.points.__miniscaleImperialTopRight = new this.Point(so.at.x + i, so.at.y - i)
|
||||
this.points.__miniscaleImperialBottomLeft = new this.Point(so.at.x - i, so.at.y + i)
|
||||
this.points.__miniscaleImperialBottomRight = new this.Point(so.at.x + i, so.at.y + i)
|
||||
// Text anchor points
|
||||
this.points.__scaleboxMetric = new this.Point(so.at.x, so.at.y - 2)
|
||||
this.points.__scaleboxImperial = new this.Point(so.at.x, so.at.y + 8)
|
||||
this.points.__miniscaleMetric = new this.Point(so.at.x, so.at.y - 2)
|
||||
this.points.__miniscaleImperial = new this.Point(so.at.x, so.at.y + 8)
|
||||
// Rotation
|
||||
if (so.rotate) {
|
||||
let points = [
|
||||
'__scaleboxMetricTopLeft',
|
||||
'__scaleboxMetricTopRight',
|
||||
'__scaleboxMetricBottomLeft',
|
||||
'__scaleboxMetricBottomRight',
|
||||
'__scaleboxImperialTopLeft',
|
||||
'__scaleboxImperialTopRight',
|
||||
'__scaleboxImperialBottomLeft',
|
||||
'__scaleboxImperialBottomRight',
|
||||
'__scaleboxMetric',
|
||||
'__scaleboxImperial'
|
||||
'__miniscaleMetricTopLeft',
|
||||
'__miniscaleMetricTopRight',
|
||||
'__miniscaleMetricBottomLeft',
|
||||
'__miniscaleMetricBottomRight',
|
||||
'__miniscaleImperialTopLeft',
|
||||
'__miniscaleImperialTopRight',
|
||||
'__miniscaleImperialBottomLeft',
|
||||
'__miniscaleImperialBottomRight',
|
||||
'__miniscaleMetric',
|
||||
'__miniscaleImperial'
|
||||
]
|
||||
for (let pid of points) this.points[pid] = this.points[pid].rotate(so.rotate, so.at)
|
||||
for (let pid of points.slice(8)) {
|
||||
|
@ -58,25 +54,25 @@ export default function(so) {
|
|||
}
|
||||
}
|
||||
// Paths
|
||||
this.paths.__scaleboxImperial = new this.Path()
|
||||
this.paths.__miniscaleImperial = new this.Path()
|
||||
.attr('class', 'scalebox imperial')
|
||||
.move(this.points.__scaleboxImperialTopLeft)
|
||||
.line(this.points.__scaleboxImperialBottomLeft)
|
||||
.line(this.points.__scaleboxImperialBottomRight)
|
||||
.line(this.points.__scaleboxImperialTopRight)
|
||||
.move(this.points.__miniscaleImperialTopLeft)
|
||||
.line(this.points.__miniscaleImperialBottomLeft)
|
||||
.line(this.points.__miniscaleImperialBottomRight)
|
||||
.line(this.points.__miniscaleImperialTopRight)
|
||||
.close()
|
||||
this.paths.__scaleboxMetric = new this.Path()
|
||||
this.paths.__miniscaleMetric = new this.Path()
|
||||
.attr('class', 'scalebox metric')
|
||||
.move(this.points.__scaleboxMetricTopLeft)
|
||||
.line(this.points.__scaleboxMetricBottomLeft)
|
||||
.line(this.points.__scaleboxMetricBottomRight)
|
||||
.line(this.points.__scaleboxMetricTopRight)
|
||||
.move(this.points.__miniscaleMetricTopLeft)
|
||||
.line(this.points.__miniscaleMetricBottomLeft)
|
||||
.line(this.points.__miniscaleMetricBottomRight)
|
||||
.line(this.points.__miniscaleMetricTopRight)
|
||||
.close()
|
||||
// Text
|
||||
this.points.__scaleboxMetric = this.points.__scaleboxMetric
|
||||
this.points.__miniscaleMetric = this.points.__miniscaleMetric
|
||||
.attr('data-text', '2.5cm x 2.5cm')
|
||||
.attr('data-text-class', 'text-xs center')
|
||||
this.points.__scaleboxImperial = this.points.__scaleboxImperial
|
||||
this.points.__miniscaleImperial = this.points.__miniscaleImperial
|
||||
.attr('data-text', '1" x 1"')
|
||||
.attr('data-text-class', 'text-xs center ')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue