1
0
Fork 0
freesewing/packages/simon/src/buttonholeplacket.js

178 lines
5.8 KiB
JavaScript
Raw Normal View History

2019-08-03 15:03:33 +02:00
import { addButtonHoles } from './shared'
2018-12-23 13:57:40 +01:00
export default (part) => {
2018-12-27 15:04:32 +01:00
let {
utils,
sa,
Point,
points,
Path,
paths,
Snippet,
snippets,
complete,
paperless,
macro,
options
2019-08-03 15:03:33 +02:00
} = part.shorthand()
if (!options.seperateButtonholePlacket || options.buttonholePlacketStyle !== 'classic') {
part.paths = {}
part.snippets = {}
part.points = {}
return part
2018-12-23 14:54:34 +01:00
}
2019-08-03 15:03:33 +02:00
for (let id of Object.keys(part.paths)) delete part.paths[id]
let width = options.buttonholePlacketWidth
let fold = options.buttonholePlacketFoldWidth
2018-12-23 13:57:40 +01:00
points.topInnerEdge = utils.lineIntersectsCurve(
new Point(points.cfNeck.x + fold * 2, points.cfNeck.y + 20),
new Point(points.cfNeck.x + fold * 2, points.cfNeck.y - 20),
points.cfNeck,
points.cfNeckCp1,
points.neckCp2Front,
points.neck
2019-08-03 15:03:33 +02:00
)
points.bottomInnerEdge = new Point(points.topInnerEdge.x, points.cfHem.y)
points.placketCfNeck = points.cfNeck.shift(180, fold * 2)
points.placketTopInnerEdgeFold = points.placketCfNeck.shift(0, width / 2)
points.placketTopInnerEdgeOver = points.placketCfNeck.shift(0, width / 2 - fold)
points.placketTopInnerEdgeUnder = points.placketCfNeck.shift(0, width / 2 + fold)
points.placketTopOuterEdgeFold = points.placketCfNeck.shift(180, width / 2)
points.placketTopOuterEdgeOver = points.placketCfNeck.shift(180, width / 2 - fold)
points.placketTopOuterEdgeUnder = points.placketCfNeck.shift(180, width / 2 + fold)
points.placketCfHem = points.cfHem.shift(180, fold * 2)
points.placketBottomInnerEdgeFold = points.placketCfHem.shift(0, width / 2)
points.placketBottomInnerEdgeOver = points.placketCfHem.shift(0, width / 2 - fold)
points.placketBottomInnerEdgeUnder = points.placketCfHem.shift(0, width / 2 + fold)
points.placketBottomOuterEdgeFold = points.placketCfHem.shift(180, width / 2)
points.placketBottomOuterEdgeOver = points.placketCfHem.shift(180, width / 2 - fold)
points.placketBottomOuterEdgeUnder = points.placketCfHem.shift(180, width / 2 + fold)
points.placketTopEdge = points.placketTopOuterEdgeFold.shift(180, width)
points.placketBottomEdge = points.placketBottomOuterEdgeFold.shift(180, width)
2018-12-23 13:57:40 +01:00
paths.saBase = new Path()
.move(points.placketTopEdge)
.line(points.cfNeck)
.curve(points.cfNeckCp1, points.neckCp2Front, points.neck)
.split(points.topInnerEdge)[0]
2019-08-03 15:03:33 +02:00
.line(points.bottomInnerEdge)
2018-12-23 13:57:40 +01:00
paths.seam = paths.saBase.clone().line(points.placketBottomEdge).close().attr('class', 'fabric')
2018-12-23 13:57:40 +01:00
// Complete pattern?
if (complete) {
// Placket help lines
paths.frontCenter = new Path()
.move(points.placketCfNeck)
.line(points.placketCfHem)
2019-08-03 15:03:33 +02:00
.attr('class', 'help')
2018-12-23 13:57:40 +01:00
paths.placketInnerEdgeFold = new Path()
.move(points.placketTopInnerEdgeFold)
.line(points.placketBottomInnerEdgeFold)
2019-08-03 15:03:33 +02:00
.attr('class', 'dotted')
2018-12-23 13:57:40 +01:00
paths.placketInnerEdgeOver = new Path()
.move(points.placketTopInnerEdgeOver)
.line(points.placketBottomInnerEdgeOver)
2019-08-03 15:03:33 +02:00
.attr('class', 'dotted')
2018-12-23 13:57:40 +01:00
paths.placketOuterEdgeFold = new Path()
.move(points.placketTopOuterEdgeFold)
.line(points.placketBottomOuterEdgeFold)
2019-08-03 15:03:33 +02:00
.attr('class', 'dotted')
2018-12-23 13:57:40 +01:00
paths.placketOuterEdgeOver = new Path()
.move(points.placketTopOuterEdgeOver)
.line(points.placketBottomOuterEdgeOver)
2019-08-03 15:03:33 +02:00
.attr('class', 'dotted')
2018-12-23 13:57:40 +01:00
paths.placketOuterEdgeUnder = new Path()
.move(points.placketTopOuterEdgeUnder)
.line(points.placketBottomOuterEdgeUnder)
2019-08-03 15:03:33 +02:00
.attr('class', 'dotted')
2018-12-23 13:57:40 +01:00
// Notches
2019-08-03 15:03:33 +02:00
snippets['cfArmhole-notch'].anchor.x = points.cfArmhole.x - fold * 2
snippets['cfWaist-notch'].anchor.x = points.cfArmhole.x - fold * 2
// This notch is not available in Simone
if (typeof snippets['cfHips-notch'] !== 'undefined')
snippets['cfHips-notch'].anchor.x = points.cfArmhole.x - fold * 2
2018-12-23 13:57:40 +01:00
// Buttons
2019-08-03 15:03:33 +02:00
addButtonHoles(part, 'placketCfNeck')
2018-12-23 13:57:40 +01:00
// Grainline
2019-08-03 15:03:33 +02:00
points.grainlineFrom = points.placketBottomEdge.shift(0, width / 2)
points.grainlineTo = points.placketTopEdge.shift(0, width / 2)
macro('grainline', {
2018-12-23 13:57:40 +01:00
from: points.grainlineFrom,
to: points.grainlineTo
2019-08-03 15:03:33 +02:00
})
2018-12-23 13:57:40 +01:00
// Title
2019-08-03 15:03:33 +02:00
points.title = new Point(points.placketCfNeck.x, points.cfArmhole.y)
macro('title', {
2018-12-23 13:57:40 +01:00
at: points.title,
2019-08-03 15:03:33 +02:00
nr: '2b',
title: 'buttonholePlacket',
2018-12-23 13:57:40 +01:00
scale: 0.75,
rotation: -90
2019-08-03 15:03:33 +02:00
})
2018-12-23 13:57:40 +01:00
// Logo
2019-08-03 15:03:33 +02:00
points.logo = points.title.shift(-90, 120)
snippets.logo = new Snippet('logo', points.logo)
.attr('data-scale', 0.5)
.attr('data-rotate', -90)
2018-12-23 13:57:40 +01:00
if (sa) {
2019-08-03 15:03:33 +02:00
paths.sa = paths.saBase.offset(sa * -1)
2018-12-23 13:57:40 +01:00
paths.sa
2019-08-03 15:03:33 +02:00
.line(new Point(points.bottomInnerEdge.x + sa, points.bottomInnerEdge.y + 3 * sa))
.line(new Point(points.placketBottomEdge.x, points.placketBottomEdge.y + 3 * sa))
2018-12-23 13:57:40 +01:00
.line(points.placketBottomEdge)
.move(points.placketTopEdge)
.line(paths.sa.start())
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric sa')
2018-12-23 13:57:40 +01:00
}
}
// Paperless?
if (paperless) {
2019-08-03 15:03:33 +02:00
let offset = 0
2018-12-28 15:42:53 +01:00
for (let pid of [
2019-08-03 15:03:33 +02:00
'placketBottomOuterEdgeUnder',
'placketBottomOuterEdgeFold',
'placketBottomOuterEdgeOver',
'placketCfHem',
'placketBottomInnerEdgeOver',
'placketBottomInnerEdgeFold',
'placketBottomInnerEdgeUnder'
2018-12-28 15:42:53 +01:00
]) {
2019-08-03 15:03:33 +02:00
offset += 15
macro('hd', {
2018-12-28 15:42:53 +01:00
from: points.placketBottomEdge,
to: points[pid],
y: points.placketBottomEdge.y + offset + 3 * sa
2019-08-03 15:03:33 +02:00
})
2018-12-28 15:42:53 +01:00
}
2019-08-03 15:03:33 +02:00
points.button0 = points.placketTopEdge
let j
2018-12-28 15:42:53 +01:00
for (let i = 0; i < options.buttons; i++) {
2019-08-03 15:03:33 +02:00
j = i + 1
macro('vd', {
from: points['button' + j],
to: points['button' + i],
2018-12-28 15:42:53 +01:00
x: points.placketTopEdge.x - 15
2019-08-03 15:03:33 +02:00
})
2018-12-28 15:42:53 +01:00
}
2019-08-03 15:03:33 +02:00
macro('vd', {
2018-12-28 15:42:53 +01:00
from: points.placketBottomEdge,
to: points.placketTopEdge,
x: points.placketTopEdge.x - 30
2019-08-03 15:03:33 +02:00
})
2018-12-23 13:57:40 +01:00
}
2019-08-03 15:03:33 +02:00
return part
}