1
0
Fork 0
freesewing/designs/carlton/src/belt.mjs

125 lines
3 KiB
JavaScript
Raw Normal View History

2022-09-04 11:37:23 -07:00
import { back } from './back.mjs'
2022-09-11 12:54:41 +02:00
function draftCarltonBelt({
sa,
snippets,
Snippet,
store,
points,
macro,
utils,
2022-09-11 12:54:41 +02:00
Point,
paths,
Path,
part,
}) {
2023-09-15 16:54:22 +02:00
const length = 1.6 * (store.get('cbToDart') + store.get('dartToSide'))
const width = store.get('beltWidth')
2019-03-25 18:20:15 +01:00
2019-08-03 15:03:33 +02:00
points.topLeft = new Point(0, 0)
points.topRight = new Point(length, 0)
points.bottomLeft = new Point(0, width)
points.bottomRight = new Point(length, width)
points.button = new Point(width / 2, width / 2)
// Macros will return the auto-generated IDs
const ids = {
roundTop: macro('round', {
id: 'roundTop',
from: points.topRight,
to: points.bottomLeft,
via: points.topLeft,
radius: width / 4,
}),
roundBottom: macro('round', {
id: 'roundBottom',
from: points.topLeft,
to: points.bottomRight,
via: points.bottomLeft,
radius: width / 4,
}),
}
// Create points from them with easy names
for (const side in ids) {
for (const id of ['start', 'cp1', 'cp2', 'end']) {
points[`${side}${utils.capitalize(id)}`] = points[ids[side].points[id]].copy()
}
}
2019-03-25 18:20:15 +01:00
// Paths
paths.seam = new Path()
.move(points.roundTopStart)
.curve(points.roundTopCp1, points.roundTopCp2, points.roundTopEnd)
.line(points.roundBottomStart)
.curve(points.roundBottomCp1, points.roundBottomCp2, points.roundBottomEnd)
.line(points.bottomRight)
.line(points.topRight)
.line(points.roundTopStart)
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2019-03-25 18:20:15 +01:00
2023-09-15 16:54:22 +02:00
if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
2023-03-12 11:29:37 -05:00
2023-09-15 16:54:22 +02:00
/*
* Annotations
*/
2023-09-15 16:54:22 +02:00
// Cut list
store.cutlist.addCut({ cut: 4, from: 'fabric' })
2023-09-15 16:54:22 +02:00
// Button & buttonhole
snippets.button = new Snippet('button', points.button).attr('data-scale', 2)
snippets.buttonhole = new Snippet('buttonhole', points.button).scale(2).rotate(90)
// Title
points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2)
macro('title', {
at: points.title,
nr: 6,
title: 'belt',
})
// Logo
points.logo = new Point(points.bottomRight.x * 0.75, points.bottomRight.y * 0.65)
snippets.logo = new Snippet('logo', points.logo)
// Notches
snippets.waistNotch = new Snippet(
'notch',
points.bottomRight.shiftFractionTowards(points.topRight, 0.5)
)
// Dimensions
macro('hd', {
id: 'wRoundedCorner',
from: points.roundBottomStart,
to: points.roundBottomEnd,
y: points.roundBottomEnd.y + sa + 15,
})
macro('hd', {
id: 'wToButton',
from: points.roundBottomStart,
to: points.button,
y: points.roundBottomEnd.y + sa + 30,
})
macro('hd', {
id: 'wFull',
from: points.roundBottomStart,
to: points.bottomRight,
y: points.roundBottomEnd.y + sa + 45,
})
macro('vd', {
id: 'hFull',
from: points.bottomRight,
to: points.topRight,
x: points.topRight.x + sa + 15,
})
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
}
2022-09-04 11:37:23 -07:00
export const belt = {
name: 'carlton.belt',
after: back,
draft: draftCarltonBelt,
}