1
0
Fork 0

chore(breanna): Port to v3 stage 2

This commit is contained in:
joostdecock 2022-09-10 20:35:46 +02:00
parent a4983dfdc6
commit b8fd8a4d19
18 changed files with 98 additions and 114 deletions

View file

@ -1,8 +1,7 @@
import { base } from './base.mjs'
import { pluginBundle } from '@freesewing/plugin-bundle'
function draftBreannaBack (part) {
let {
function draftBreannaBack({
sa,
points,
Path,
@ -16,8 +15,8 @@ function draftBreannaBack (part) {
options,
utils,
store,
} = part.shorthand()
part,
}) {
// Shoulder dart
if (options.shoulderDart) {
points.shoulderDartCenter = points.hps.shiftFractionTowards(points.shoulder, 0.5)
@ -280,10 +279,9 @@ function draftBreannaBack (part) {
return part
}
export const back = {
from: base,
name: 'breanna.back',
plugins: [ pluginBundle ],
plugins: [pluginBundle],
draft: draftBreannaBack,
}

View file

@ -1,6 +1,4 @@
function draftBreannaBase (part) {
let { store, points, Point, measurements, options, utils } = part.shorthand()
function draftBreannaBase({ store, points, Point, measurements, options, utils, part }) {
// HPS
points.hps = new Point((measurements.neck * (1 + options.collarEase)) / options.collarFactor, 0)

View file

@ -1,5 +1,5 @@
// Where to cut for a dart in a given location
export function getDartInsertionPoint (points, utils, loc, angle) {
export function getDartInsertionPoint(points, utils, loc, angle) {
let tip = points.bustPoint
switch (loc) {
case 700:
@ -46,7 +46,7 @@ export function getDartInsertionPoint (points, utils, loc, angle) {
}
// What points need to be rotated after cutting the primary bust dart
export function getPrimaryDartRotationList (loc) {
export function getPrimaryDartRotationList(loc) {
let rotate = ['cfWaist']
if (loc >= 1100) rotate.push('cfNeck')
if (loc >= 1130) rotate.push('hpsCp2')
@ -61,7 +61,7 @@ export function getPrimaryDartRotationList (loc) {
// What points need to be rotated after cutting the secondary bust dart
// loc1 = primary bust dart location
// loc2 = secondary bust dart location
export function getSecondaryDartRotationList (loc1, loc2) {
export function getSecondaryDartRotationList(loc1, loc2) {
let rotate = ['primaryBustDart1']
if (loc1 <= 700 && loc2 >= 800) rotate.push('cfWaist')
if (loc1 <= 1000 && loc2 >= 1100) rotate.push('cfNeck')
@ -74,7 +74,7 @@ export function getSecondaryDartRotationList (loc1, loc2) {
return rotate
}
export function getDartLocationsAsNumbers (options) {
export function getDartLocationsAsNumbers(options) {
let loc1 = options.primaryBustDart
let loc2 = options.secondaryBustDart
loc1 = Number(loc1.slice(0, 2) + loc1.slice(-2))
@ -111,7 +111,7 @@ export const getSaDartPaths = (Path, points) => [
* still need to turn them into darts that make sense in practice.
* This method takes care of that
*/
export function applyBustDarts (points, options, utils) {
export function applyBustDarts(points, options, utils) {
// Find the bust dart edge point
points.primaryBustDartEdge = utils.beamsIntersect(
points.primaryBustDart1,

View file

@ -1,9 +1,17 @@
import { base } from './base.mjs'
import { back } from './back.mjs'
function draftBreannaFrontBase (part) {
let { points, Path, paths, Point, measurements, options, utils, store } = part.shorthand()
function draftBreannaFrontBase({
points,
Path,
paths,
Point,
measurements,
options,
utils,
store,
part,
}) {
// Fit neck
points.cfHps = points.cbHps.clone()
points.cfNeck = points.hps.rotate(-90, points.cfHps)

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryAt1100 (part) {
export function frontWithPrimaryAt1100(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('secondaryBustDartLocation')) {

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryAt1130 (part) {
export function frontWithPrimaryAt1130(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('secondaryBustDartLocation')) {

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryAt1200 (part) {
export function frontWithPrimaryAt1200(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('secondaryBustDartLocation')) {

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryAt1300 (part) {
export function frontWithPrimaryAt1300(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('secondaryBustDartLocation')) {

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryAt1330 (part) {
export function frontWithPrimaryAt1330(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('secondaryBustDartLocation')) {

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryAt1400 (part) {
export function frontWithPrimaryAt1400(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('secondaryBustDartLocation')) {

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryAt600 (part) {
export function frontWithPrimaryAt600(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('secondaryBustDartLocation')) {

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryAt700 (part) {
export function frontWithPrimaryAt700(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('secondaryBustDartLocation')) {

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryAt800 (part) {
export function frontWithPrimaryAt800(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('secondaryBustDartLocation')) {

View file

@ -1,4 +1,4 @@
export function frontWithPrimaryOnly (part) {
export function frontWithPrimaryOnly(part) {
let { points, Path, store } = part.shorthand()
switch (store.get('primaryBustDartLocation')) {

View file

@ -21,8 +21,7 @@ import {
getSaDartPaths,
} from './dart-utils.mjs'
function draftBreannaFront (part) {
let {
function draftBreannaFront({
options,
store,
utils,
@ -35,8 +34,8 @@ function draftBreannaFront (part) {
macro,
snippets,
Snippet,
} = part.shorthand()
part,
}) {
/*
* We're starting from front-base here, which is injected into this part
* It has a single primary bust dart at 06:00

View file

@ -12,7 +12,7 @@ import { sleeveCap } from './sleevecap.mjs'
// Create design
const Breanna = new Design({
data,
parts: [ back, front, sleeve ]
parts: [back, front, sleeve],
})
// Named exports

View file

@ -3,8 +3,8 @@ import { front } from './front.mjs'
import { frontBase } from './front-base.mjs'
import { back } from './back.mjs'
function draftBreannaSleeve (part) {
let {
function draftBreannaSleeve(params) {
const {
store,
sa,
measurements,
@ -18,7 +18,8 @@ function draftBreannaSleeve (part) {
complete,
paperless,
macro,
} = part.shorthand()
part,
} = params
// Wrist
let top = paths.sleevecap.edge('topLeft').y
@ -70,7 +71,8 @@ function draftBreannaSleeve (part) {
if (q1Len === frontTarget) points.frontNotch = points.capQ1.clone()
else if (q1Len > frontTarget) points.frontNotch = q1.shiftAlong(frontTarget)
else {
let q2 = new Path().move(points.capQ1)
let q2 = new Path()
.move(points.capQ1)
.curve(points.capQ1Cp2, points.capQ2Cp1, points.capQ2)
.curve(points.capQ2Cp2, points.capQ3Cp1, points.capQ3)
points.frontNotch = q2.shiftAlong(frontTarget - q1Len)
@ -81,7 +83,8 @@ function draftBreannaSleeve (part) {
if (q4Len === backTarget) points.backNotch = points.capQ4.clone()
else if (q4Len > backTarget) points.backNotch = q4.shiftAlong(backTarget)
else {
let q3 = new Path().move(points.capQ4)
let q3 = new Path()
.move(points.capQ4)
.curve(points.capQ4Cp1, points.capQ3Cp2, points.capQ3)
.curve(points.capQ3Cp1, points.capQ2Cp2, points.capQ2)
points.backNotch = q3.shiftAlong(backTarget - q4Len)
@ -125,11 +128,8 @@ function draftBreannaSleeve (part) {
export const sleeve = {
name: 'breanna.sleeve',
from: sleeveCap,
after: [ front, frontBase, back ],
measurements: [
'shoulderToWrist',
'wrist',
],
after: [front, frontBase, back],
measurements: ['shoulderToWrist', 'wrist'],
options: {
cuffEase: { pct: 20, min: 0, max: 50, menu: 'fit' },
sleeveLengthBonus: { pct: 0, min: -40, max: 10, menu: 'style' },

View file

@ -33,8 +33,8 @@ function sleevecapAdjust(store, twoBacks = false, options = null) {
store.set('sleeveFactor', factor)
}
function draftSleevecap(part, run) {
let { store, measurements, options, Point, points, Path, paths } = part.shorthand()
function draftSleevecap(params, run) {
let { store, measurements, options, Point, points, Path, paths, part } = params
// Sleeve center axis
points.centerBiceps = new Point(0, 0)
points.centerCap = points.centerBiceps.shift(
@ -153,8 +153,8 @@ function draftSleevecap(part, run) {
}
}
function redrawSleevecapFront(part, delta) {
let { store, points, Path, paths } = part.shorthand()
function redrawSleevecapFront(params, delta) {
let { store, points, Path, paths } = params
let factor = points.bicepsRight.x
for (let p of [
'bicepsRight',
@ -184,14 +184,14 @@ function redrawSleevecapFront(part, delta) {
store.set('sleevecapLength', paths.sleevecap.length())
}
function draftBreannaSleevecap (part) {
let { store, options, Point, points, paths } = part.shorthand()
function draftBreannaSleevecap(params) {
const { store, options, Point, points, paths, part } = params
// Step 1: sleevecap for 2 backs joined together (twoBacks = true)
store.set('sleeveFactor', 1)
let run = 0
do {
draftSleevecap(part, run)
draftSleevecap(params, run)
sleevecapAdjust(store, true, options)
run++
} while (
@ -209,7 +209,7 @@ function draftBreannaSleevecap (part) {
// Step 2: sleevecap for back joined with front (twoBacks = false)
run = 0
do {
redrawSleevecapFront(part, sleevecapDelta(store))
redrawSleevecapFront(params, sleevecapDelta(store))
sleevecapAdjust(store)
run++
} while (options.breannaFitSleeve === true && run < 50 && Math.abs(sleevecapDelta(store)) > 2)
@ -226,47 +226,28 @@ function draftBreannaSleevecap (part) {
export const sleeveCap = {
name: 'breanna.sleeveCap',
hide: true,
after: [ front, frontBase, back ],
after: [front, frontBase, back],
options: {
bicepsEase: { pct: 15, min: 0, max: 50, menu: 'fit' },
sleevecapEase: { pct: 0.5, min: 0, max: 2.5,
menu: 'advanced.sleevecap' },
sleevecapTopFactorX: { pct: 50, min: 25, max: 75,
menu: 'advanced.sleevecap' },
sleevecapTopFactorY: { pct: 110, min: 35, max: 165,
menu: 'advanced.sleevecap' },
sleevecapBackFactorX: { pct: 45, min: 35, max: 55,
menu: 'advanced.sleevecap' },
sleevecapBackFactorY: { pct: 33, min: 30, max: 65,
menu: 'advanced.sleevecap' },
sleevecapFrontFactorX: { pct: 55, min: 35, max: 65,
menu: 'advanced.sleevecap' },
sleevecapFrontFactorY: { pct: 33, min: 30, max: 65,
menu: 'advanced.sleevecap' },
sleevecapQ1Offset: { pct: 3, min: 0, max: 7,
menu: 'advanced.sleevecap' },
sleevecapQ2Offset: { pct: 5.5, min: 0, max: 7,
menu: 'advanced.sleevecap' },
sleevecapQ3Offset: { pct: 4.5, min: 0, max: 7,
menu: 'advanced.sleevecap' },
sleevecapQ4Offset: { pct: 1, min: 0, max: 7,
menu: 'advanced.sleevecap' },
sleevecapQ1Spread1: { pct: 10, min: 4, max: 20,
menu: 'advanced.sleevecap' },
sleevecapQ1Spread2: { pct: 12.5, min: 4, max: 20,
menu: 'advanced.sleevecap' },
sleevecapQ2Spread1: { pct: 12.5, min: 4, max: 20,
menu: 'advanced.sleevecap' },
sleevecapQ2Spread2: { pct: 12.5, min: 4, max: 20,
menu: 'advanced.sleevecap' },
sleevecapQ3Spread1: { pct: 12.5, min: 4, max: 20,
menu: 'advanced.sleevecap' },
sleevecapQ3Spread2: { pct: 8, min: 4, max: 20,
menu: 'advanced.sleevecap' },
sleevecapQ4Spread1: { pct: 7, min: 4, max: 20,
menu: 'advanced.sleevecap' },
sleevecapQ4Spread2: { pct: 7, min: 4, max: 20,
menu: 'advanced.sleevecap' },
sleevecapEase: { pct: 0.5, min: 0, max: 2.5, menu: 'advanced.sleevecap' },
sleevecapTopFactorX: { pct: 50, min: 25, max: 75, menu: 'advanced.sleevecap' },
sleevecapTopFactorY: { pct: 110, min: 35, max: 165, menu: 'advanced.sleevecap' },
sleevecapBackFactorX: { pct: 45, min: 35, max: 55, menu: 'advanced.sleevecap' },
sleevecapBackFactorY: { pct: 33, min: 30, max: 65, menu: 'advanced.sleevecap' },
sleevecapFrontFactorX: { pct: 55, min: 35, max: 65, menu: 'advanced.sleevecap' },
sleevecapFrontFactorY: { pct: 33, min: 30, max: 65, menu: 'advanced.sleevecap' },
sleevecapQ1Offset: { pct: 3, min: 0, max: 7, menu: 'advanced.sleevecap' },
sleevecapQ2Offset: { pct: 5.5, min: 0, max: 7, menu: 'advanced.sleevecap' },
sleevecapQ3Offset: { pct: 4.5, min: 0, max: 7, menu: 'advanced.sleevecap' },
sleevecapQ4Offset: { pct: 1, min: 0, max: 7, menu: 'advanced.sleevecap' },
sleevecapQ1Spread1: { pct: 10, min: 4, max: 20, menu: 'advanced.sleevecap' },
sleevecapQ1Spread2: { pct: 12.5, min: 4, max: 20, menu: 'advanced.sleevecap' },
sleevecapQ2Spread1: { pct: 12.5, min: 4, max: 20, menu: 'advanced.sleevecap' },
sleevecapQ2Spread2: { pct: 12.5, min: 4, max: 20, menu: 'advanced.sleevecap' },
sleevecapQ3Spread1: { pct: 12.5, min: 4, max: 20, menu: 'advanced.sleevecap' },
sleevecapQ3Spread2: { pct: 8, min: 4, max: 20, menu: 'advanced.sleevecap' },
sleevecapQ4Spread1: { pct: 7, min: 4, max: 20, menu: 'advanced.sleevecap' },
sleevecapQ4Spread2: { pct: 7, min: 4, max: 20, menu: 'advanced.sleevecap' },
},
draft: draftBreannaSleevecap,
}