Honor scale setting in miniscale
This commit is contained in:
parent
acf3fff4f9
commit
83a153eaf5
2 changed files with 53 additions and 6 deletions
|
@ -17,8 +17,25 @@ export default function (so) {
|
|||
for (let id of ['__miniscaleMetric', '__miniscaleImperial']) delete this.paths[id]
|
||||
return true
|
||||
}
|
||||
const m = 12.5
|
||||
const i = 12.7
|
||||
|
||||
const scale = this.context.settings.scale
|
||||
|
||||
// Convert scale to a value between 0 and 5, inclusive.
|
||||
const scaleIndex = Math.ceil(6 * Math.max(0.1, Math.min(1, this.context.settings.scale))) - 1
|
||||
|
||||
// Metric size in mm / display value and imperial size in mm / display value for each scale index.
|
||||
const sizes = [
|
||||
[10, "1cm", 25.4 * 0.375, '⅜″'],
|
||||
[13, "1.3cm", 25.4 * 0.5, '½″'],
|
||||
[16, "1.6cm", 25.4 * 0.625, '⅝″'],
|
||||
[19, "1.9cm", 25.4 * 0.75, '¾″'],
|
||||
[22, "2.2cm", 25.4 * 0.875, '⅞″'],
|
||||
[25, "2.5cm", 25.4 * 1, '1″'],
|
||||
]
|
||||
const m = sizes[scaleIndex][0] / 2
|
||||
const i = sizes[scaleIndex][2] / 2
|
||||
const metricDisplaySize = sizes[scaleIndex][1]
|
||||
const imperialDisplaySize = sizes[scaleIndex][3]
|
||||
// Box points
|
||||
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)
|
||||
|
@ -29,8 +46,8 @@ export default function (so) {
|
|||
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.__miniscaleMetric = new this.Point(so.at.x, so.at.y - 2)
|
||||
this.points.__miniscaleImperial = new this.Point(so.at.x, so.at.y + 8)
|
||||
this.points.__miniscaleMetric = new this.Point(so.at.x, so.at.y - 2 * scale)
|
||||
this.points.__miniscaleImperial = new this.Point(so.at.x, so.at.y + 8 * scale)
|
||||
// Rotation
|
||||
if (so.rotate) {
|
||||
let points = [
|
||||
|
@ -70,9 +87,9 @@ export default function (so) {
|
|||
.close()
|
||||
// Text
|
||||
this.points.__miniscaleMetric = this.points.__miniscaleMetric
|
||||
.attr('data-text', '2.5cm x 2.5cm')
|
||||
.attr('data-text', `${metricDisplaySize} x ${metricDisplaySize}`)
|
||||
.attr('data-text-class', 'text-xs center')
|
||||
this.points.__miniscaleImperial = this.points.__miniscaleImperial
|
||||
.attr('data-text', '1" x 1"')
|
||||
.attr('data-text', `${imperialDisplaySize} x ${imperialDisplaySize}`)
|
||||
.attr('data-text-class', 'text-xs center ')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue