1
0
Fork 0
freesewing/packages/carlton/src/back.js

227 lines
6.1 KiB
JavaScript
Raw Normal View History

2019-08-03 15:03:33 +02:00
import { calculateRatios } from './shared'
2019-03-25 18:20:15 +01:00
export default function (part) {
2019-08-03 15:03:33 +02:00
let {
paperless,
sa,
snippets,
Snippet,
store,
complete,
points,
measurements,
options,
macro,
Point,
paths,
Path
} = part.shorthand()
calculateRatios(part)
2019-03-25 18:20:15 +01:00
// Belt width
let bw = measurements.hpsToWaistBack * options.beltWidth
2019-08-03 15:03:33 +02:00
store.set('beltWidth', bw)
2019-03-25 18:20:15 +01:00
// Box pleat (bp)
2019-08-03 15:03:33 +02:00
points.bpStart = new Point(0, points.armholePitch.y)
points.bpTop = new Point(measurements.chest * options.backPleat * -1, points.armholePitch.y)
2019-08-03 15:03:33 +02:00
points.bpBottom = new Point(points.bpTop.x, points.cbWaist.y - bw / 2)
points.bpTriangleEdge = points.bpStart.shift(0, points.bpTop.dx(points.bpStart) * 0.6)
points.bpTriangleTip = points.bpStart.shift(90, points.bpStart.dx(points.bpTriangleEdge))
2019-03-25 18:20:15 +01:00
// Waist shaping
points.waist = new Point(
2019-08-03 15:03:33 +02:00
store.get('chest') / 4 - store.get('waistReduction') / 8,
2019-03-25 18:20:15 +01:00
points.bpBottom.y
2019-08-03 15:03:33 +02:00
)
points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 3)
points.cbWaist = new Point(0, points.bpBottom.y)
2019-03-25 18:20:15 +01:00
// Dart
2019-08-03 15:03:33 +02:00
points.dartCenter = points.cbWaist.shiftFractionTowards(points.waist, 0.4)
points.dartTip = points.dartCenter.shift(90, points.armhole.dy(points.dartCenter) * 0.85)
points.dartRight = points.dartCenter.shift(0, store.get('waistReduction') / 8)
points.dartLeft = points.dartRight.flipX(points.dartCenter)
points.dartLeftCp = points.dartLeft.shift(90, points.dartTip.dy(points.dartCenter) * 0.6)
points.dartRightCp = points.dartLeftCp.flipX(points.dartCenter)
2019-03-25 18:20:15 +01:00
2019-08-03 15:03:33 +02:00
store.set('cbToDart', points.dartLeft.x)
store.set('dartToSide', points.dartRight.dx(points.waist))
2019-03-25 18:20:15 +01:00
// Back stay (bs)
2019-08-03 15:03:33 +02:00
points.bsCp1 = points.bpStart.shiftFractionTowards(points.armholePitch, 0.5)
points.bsCp2 = points.armhole.shiftFractionTowards(points.cbArmhole, 0.3)
2019-03-25 18:20:15 +01:00
// Store collar length
store.set(
2019-08-03 15:03:33 +02:00
'backCollarLength',
new Path().move(points.cbNeck)._curve(points.neckCp2, points.neck).length()
2019-08-03 15:03:33 +02:00
)
2019-03-25 18:20:15 +01:00
// Clean up
for (let i in paths) delete paths[i]
for (let i in snippets) delete snippets[i]
// Paths
2019-03-27 08:02:55 +01:00
paths.seam1 = new Path()
2019-03-25 18:20:15 +01:00
.move(points.cbNeck)
.line(points.bpStart)
.line(points.bpTop)
.line(points.bpBottom)
2019-03-27 08:02:55 +01:00
paths.dart = new Path()
.move(points.dartLeft)
2019-03-25 18:20:15 +01:00
.curve_(points.dartLeftCp, points.dartTip)
._curve(points.dartRightCp, points.dartRight)
2019-03-27 08:02:55 +01:00
paths.seam2 = new Path()
.move(points.waist)
2019-03-25 18:20:15 +01:00
.curve_(points.waistCp2, points.armhole)
.curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow)
.curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.line(points.neck)
.curve_(points.neckCp2, points.cbNeck)
paths.seam = paths.seam1.join(paths.dart).join(paths.seam2).close().attr('class', 'fabric')
2019-03-25 18:20:15 +01:00
paths.backStay = new Path()
.move(points.bpStart)
.curve(points.bsCp1, points.bsCp2, points.armhole)
2019-08-03 15:03:33 +02:00
.attr('class', 'canvas lashed')
2019-03-25 18:20:15 +01:00
2019-03-27 08:02:55 +01:00
paths.triangle = new Path()
.move(points.bpTriangleTip)
.line(points.bpTriangleEdge)
.line(points.bpStart)
2019-08-03 15:03:33 +02:00
.attr('class', 'dashed')
2019-03-27 08:02:55 +01:00
2019-03-25 18:20:15 +01:00
if (complete) {
2019-08-03 15:03:33 +02:00
macro('sprinkle', {
snippet: 'bnotch',
on: ['shoulder', 'bpTriangleTip']
2019-08-03 15:03:33 +02:00
})
macro('grainline', {
2019-03-27 08:02:55 +01:00
from: points.cbWaist,
to: points.bpStart
2019-08-03 15:03:33 +02:00
})
2019-03-27 08:02:55 +01:00
2019-08-03 15:03:33 +02:00
points.logo = new Point(points.armhole.x * 0.7, points.dartTip.y)
snippets.logo = new Snippet('logo', points.logo)
2019-03-27 08:02:55 +01:00
if (sa) {
2019-08-03 15:03:33 +02:00
paths.sa = paths.seam1
2019-03-27 08:02:55 +01:00
.line(points.waist)
.offset(sa)
.join(paths.seam2.offset(sa))
.close()
.trim()
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric sa')
2019-03-27 08:02:55 +01:00
}
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.bpBottom,
to: points.cbWaist,
y: points.cbWaist.y + 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.cbWaist,
to: points.dartLeft,
y: points.cbWaist.y + 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.dartLeft,
to: points.dartRight,
y: points.cbWaist.y + 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.dartRight,
to: points.waist,
y: points.cbWaist.y + 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.cbWaist,
to: points.waist,
y: points.cbWaist.y + 30 + sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.bpBottom,
to: points.waist,
y: points.cbWaist.y + 45 + sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-27 08:02:55 +01:00
from: points.waist,
to: points.armhole,
x: points.armhole.x + 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-27 08:02:55 +01:00
from: points.armhole,
to: points.armholePitch,
x: points.armhole.x + 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-27 08:02:55 +01:00
from: points.armhole,
to: points.shoulder,
x: points.armhole.x + 30 + sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-27 08:02:55 +01:00
from: points.waist,
to: points.shoulder,
x: points.armhole.x + 45 + sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-27 08:02:55 +01:00
from: points.dartRight,
to: points.dartTip,
x: points.dartRight.x + 15
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-27 08:02:55 +01:00
from: points.bpBottom,
to: points.bpTop,
x: points.bpTop.x - 15 - sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-27 08:02:55 +01:00
from: points.bpTop,
to: points.cbNeck,
x: points.bpTop.x - 15 - sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-27 08:02:55 +01:00
from: points.bpBottom,
to: points.neck,
x: points.bpTop.x - 30 - sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-27 08:02:55 +01:00
from: points.bpStart,
to: points.bpTriangleTip,
x: points.bpTriangleEdge.x + 15
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.bpStart,
to: points.bpTriangleEdge,
y: points.bpTriangleEdge.y + 15
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.cbNeck,
to: points.neck,
y: points.neck.y - 15 - sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.cbNeck,
to: points.armholePitch,
y: points.neck.y - 30 - sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.cbNeck,
to: points.shoulder,
y: points.neck.y - 45 - sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-27 08:02:55 +01:00
from: points.cbNeck,
to: points.armhole,
y: points.neck.y - 60 - sa
2019-08-03 15:03:33 +02:00
})
2019-03-27 08:02:55 +01:00
}
2019-03-25 18:20:15 +01:00
}
2019-08-03 15:03:33 +02:00
return part
2019-03-25 18:20:15 +01:00
}