1
0
Fork 0
freesewing/packages/tiberius/src/tunica.js

183 lines
5.6 KiB
JavaScript
Raw Normal View History

2021-10-08 17:32:12 +02:00
export default function (part) {
2021-10-10 19:11:20 +02:00
const {
2021-10-08 17:32:12 +02:00
Point,
points,
Path,
paths,
measurements,
options,
macro,
complete,
snippets,
Snippet,
sa,
paperless,
} = part.shorthand()
2021-10-10 19:11:20 +02:00
// Handle width
2021-10-15 16:13:21 +02:00
let width =
2021-10-16 12:08:02 +02:00
options.width === 'toElbow'
2021-10-15 16:13:21 +02:00
? measurements.shoulderToElbow
2021-10-16 12:08:02 +02:00
: options.width === 'toMidArm'
2021-10-15 16:13:21 +02:00
? measurements.shoulderToElbow / 2
: 0
2021-10-08 17:32:12 +02:00
let hwidth = (measurements.shoulderToShoulder / 2 + width) * options.widthBonus
2021-10-10 19:11:20 +02:00
// Some checks, can be circumvented with forceWidth
2021-10-08 17:32:12 +02:00
if (options.forceWidth === false) {
if (hwidth < measurements.waist / 4) {
hwidth = (measurements.waist / 4) * options.widthBonus
}
if (hwidth < measurements.hips / 4) {
hwidth = (measurements.hips / 4) * options.widthBonus
}
2021-10-08 17:32:12 +02:00
if (hwidth < measurements.chest / 4) {
hwidth = (measurements.chest / 4) * options.widthBonus
}
if (hwidth < measurements.seat / 4) {
hwidth = (measurements.seat / 4) * options.widthBonus
}
}
2021-10-10 19:11:20 +02:00
// Other variables
2021-10-15 16:13:21 +02:00
const hem_pos =
2021-10-16 12:08:02 +02:00
options.length === 'toKnee'
2021-10-15 16:13:21 +02:00
? measurements.waistToKnee
2021-10-16 12:08:02 +02:00
: options.length === 'toMidLeg'
2021-10-15 16:13:21 +02:00
? measurements.waistToKnee / 1.3
: measurements.waistToFloor * 0.95
2021-10-10 19:11:20 +02:00
const length = (measurements.hpsToWaistBack + hem_pos) * options.lengthBonus
const hhead = (measurements.head / 4) * options.headRatio
const armhole = (measurements.biceps / 2) * 1.3 * options.armholeDrop
const clavusWidth = (options.clavusWidth * hwidth) / 13 / options.widthBonus
// Add points
2021-10-08 17:32:12 +02:00
points.top = new Point(0, 0)
points.bottom = new Point(0, length)
points.topLeft = points.top.shift(0, -hwidth)
points.headLeft = points.top.shift(180, hhead)
2021-10-10 19:11:20 +02:00
// Don't go more narrow than head opening
points.topLeftMin = points.top.shiftFractionTowards(points.headLeft, 1.1)
if (points.topLeftMin.x < points.topLeft.x) points.topLeft.x = points.topLeftMin.x
points.bottomLeft = points.bottom.shift(0, points.bottom.dx(points.topLeft))
2021-10-08 17:32:12 +02:00
points.armholeLeft = points.topLeft.shift(-90, armhole)
// draw paths
2021-10-10 19:11:20 +02:00
paths.saBase = new Path()
2021-10-08 17:32:12 +02:00
.move(points.top)
.line(points.topLeft)
.line(points.bottomLeft)
2021-10-10 19:11:20 +02:00
.setRender(false)
2021-10-15 16:13:21 +02:00
paths.hem = new Path().move(points.bottomLeft).line(points.bottom).setRender(false)
paths.fold = new Path().move(points.bottom).line(points.top).setRender(false)
paths.seam = paths.saBase.join(paths.hem).join(paths.fold).setRender(true).attr('class', 'fabric')
2021-10-08 17:32:12 +02:00
// clavi
if (options.clavi) {
// make points
2021-10-10 19:11:20 +02:00
points.claviCenterTop = points.top.shiftFractionTowards(points.topLeft, options.clavusLocation)
points.claviRightTop = points.claviCenterTop.shift(0, clavusWidth)
points.claviLeftTop = points.claviRightTop.flipX(points.claviCenterTop)
points.claviRightBottom = new Point(points.claviRightTop.x, points.bottom.y)
points.claviLeftBottom = new Point(points.claviLeftTop.x, points.bottom.y)
// draw paths
2021-10-08 17:32:12 +02:00
paths.clavusRight = new Path()
2021-10-10 19:11:20 +02:00
.move(points.claviRightBottom)
.line(points.claviRightTop)
2021-10-08 17:32:12 +02:00
.attr('class', 'various dashed')
2021-10-10 19:11:20 +02:00
.attr('data-text', 'biasTape')
.attr('data-text-class', 'center fill-various')
2021-10-08 17:32:12 +02:00
paths.clavusLeft = new Path()
2021-10-10 19:11:20 +02:00
.move(points.claviLeftBottom)
.line(points.claviLeftTop)
2021-10-08 17:32:12 +02:00
.attr('class', 'various dashed')
2021-10-10 19:11:20 +02:00
.attr('data-text', 'biasTape')
2021-10-08 17:32:12 +02:00
.attr('data-text-class', 'center fill-various')
}
// Complete?
if (complete) {
// notches
snippets.hl = new Snippet('notch', points.headLeft)
snippets.al = new Snippet('notch', points.armholeLeft)
// cut on fold
macro('cutonfold', {
from: points.bottom,
to: points.top,
grainline: true,
})
// logo & title
2021-10-10 19:11:20 +02:00
points.midTop = points.top.shiftFractionTowards(points.headLeft, 0.5)
points.midBottom = new Point(points.midTop.x, points.bottom.y)
points.logo = points.midTop.shiftFractionTowards(points.midBottom, 0.3)
2021-10-08 17:32:12 +02:00
snippets.logo = new Snippet('logo', points.logo)
2021-10-10 19:11:20 +02:00
points.title = points.midTop.shiftFractionTowards(points.midBottom, 0.5)
2021-10-08 17:32:12 +02:00
macro('title', {
at: points.title,
nr: 1,
title: 'tunica',
})
points.__titleNr.attr('data-text-class', 'center')
points.__titleName.attr('data-text-class', 'center')
points.__titlePattern.attr('data-text-class', 'center')
// scalebox
2021-10-10 19:11:20 +02:00
points.scalebox = points.midTop.shiftFractionTowards(points.midBottom, 0.7)
2021-10-08 17:32:12 +02:00
macro('scalebox', { at: points.scalebox })
// seam allowance
if (sa) {
2021-10-10 19:11:20 +02:00
paths.sa = paths.saBase
2021-10-08 17:32:12 +02:00
.offset(sa)
.join(paths.hem.offset(sa * 2.5))
.close()
.attr('class', 'fabric sa')
}
2021-10-08 17:32:12 +02:00
// Paperless?
if (paperless) {
macro('vd', {
2021-10-10 19:11:20 +02:00
from: points.bottom,
to: points.top,
x: points.bottomLeft.x - 30 - sa,
2021-10-08 17:32:12 +02:00
})
macro('vd', {
2021-10-10 19:11:20 +02:00
from: points.bottomLeft,
to: points.armholeLeft,
x: points.armholeLeft.x - 15 - sa,
2021-10-08 17:32:12 +02:00
})
macro('vd', {
2021-10-10 19:11:20 +02:00
from: points.armholeLeft,
to: points.topLeft,
x: points.armholeLeft.x - 15 - sa,
2021-10-08 17:32:12 +02:00
})
macro('hd', {
from: points.topLeft,
to: points.top,
2021-10-10 19:11:20 +02:00
y: points.top.y - sa - (options.clavi ? 60 : 30),
2021-10-08 17:32:12 +02:00
})
macro('hd', {
to: points.top,
2021-10-10 19:11:20 +02:00
from: points.headLeft,
y: points.top.y - 15 - sa,
2021-10-08 17:32:12 +02:00
})
// for clavi
if (options.clavi) {
macro('hd', {
2021-10-10 19:11:20 +02:00
from: points.claviRightTop,
to: points.top,
y: points.top.y - 30 - sa,
2021-10-08 17:32:12 +02:00
})
macro('hd', {
2021-10-10 19:11:20 +02:00
from: points.claviLeftTop,
2021-10-08 17:32:12 +02:00
to: points.top,
2021-10-10 19:11:20 +02:00
y: points.top.y - 45 - sa,
2021-10-08 17:32:12 +02:00
})
}
}
2021-10-08 17:32:12 +02:00
}
return part
}