1
0
Fork 0

chore(trayvon): Port to v3 stage 2

This commit is contained in:
joostdecock 2022-09-11 17:07:18 +02:00
parent 809875ffac
commit 8a7d893c12
5 changed files with 59 additions and 55 deletions

View file

@ -7,12 +7,11 @@ import {
options, options,
} from './shared.mjs' } from './shared.mjs'
function trayvonFabricTail(part) { function trayvonFabricTail(params) {
const { Path, complete, macro, paths, points, paperless, sa, store, absoluteOptions } = const { Path, complete, macro, paths, points, paperless, sa, store, absoluteOptions } = params
part.shorthand()
calculateHelpers(part) calculateHelpers(params)
draftTieShape(part, store.get('backTip') * 2.5, absoluteOptions.knotWidth * 2.5, true) draftTieShape(params, store.get('backTip') * 2.5, absoluteOptions.knotWidth * 2.5, true)
paths.seam.attributes.add('class', 'fabric') paths.seam.attributes.add('class', 'fabric')
// Complete pattern? // Complete pattern?
@ -29,7 +28,7 @@ function trayvonFabricTail(part) {
// Paperless? // Paperless?
if (paperless) { if (paperless) {
tieShapeDimensions(part) tieShapeDimensions(params)
macro('ld', { macro('ld', {
from: points.tip, from: points.tip,
to: points.notch1, to: points.notch1,
@ -48,10 +47,10 @@ function trayvonFabricTail(part) {
.attr('data-text-class', 'center') .attr('data-text-class', 'center')
} }
return part return params.part
} }
function trayvonFabricTip(part) { function trayvonFabricTip(params) {
const { const {
Path, Path,
Snippet, Snippet,
@ -63,10 +62,10 @@ function trayvonFabricTip(part) {
sa, sa,
snippets, snippets,
absoluteOptions, absoluteOptions,
} = part.shorthand() } = params
calculateHelpers(part) calculateHelpers(params)
draftTieShape(part, absoluteOptions.tipWidth * 2.5, absoluteOptions.knotWidth * 2.5, true) draftTieShape(params, absoluteOptions.tipWidth * 2.5, absoluteOptions.knotWidth * 2.5, true)
paths.seam.attributes.add('class', 'fabric') paths.seam.attributes.add('class', 'fabric')
// Complete pattern? // Complete pattern?
@ -105,7 +104,7 @@ function trayvonFabricTip(part) {
.attr('data-text-class', 'center') .attr('data-text-class', 'center')
} }
return part return params.part
} }
export const fabricTail = { export const fabricTail = {

View file

@ -1,12 +1,11 @@
import { pluginBundle } from '@freesewing/plugin-bundle' import { pluginBundle } from '@freesewing/plugin-bundle'
import { draftTieShape, tieShapeDimensions, calculateHelpers, options } from './shared.mjs' import { draftTieShape, tieShapeDimensions, calculateHelpers, options } from './shared.mjs'
function trayvonInterfacingTail(part) { function trayvonInterfacingTail(params) {
const { paths, points, macro, complete, paperless, Path, store, absoluteOptions } = const { paths, points, macro, complete, paperless, Path, store, absoluteOptions } = params
part.shorthand()
calculateHelpers(part) calculateHelpers(params)
draftTieShape(part, store.get('backTip'), absoluteOptions.knotWidth) draftTieShape(params, store.get('backTip'), absoluteOptions.knotWidth)
paths.seam.attributes.add('class', 'interfacing') paths.seam.attributes.add('class', 'interfacing')
// Complete pattern? // Complete pattern?
@ -21,7 +20,7 @@ function trayvonInterfacingTail(part) {
// Paperless? // Paperless?
if (paperless) { if (paperless) {
tieShapeDimensions(part) tieShapeDimensions(params)
paths.n45 = new Path() paths.n45 = new Path()
.move(points.midLeft) .move(points.midLeft)
.line(points.midRight) .line(points.midRight)
@ -30,14 +29,14 @@ function trayvonInterfacingTail(part) {
.attr('data-text-class', 'center') .attr('data-text-class', 'center')
} }
return part return params.part
} }
function trayvonInterfacingTip(part) { function trayvonInterfacingTip(params) {
let { paths, points, macro, complete, paperless, Path, absoluteOptions } = part.shorthand() const { paths, points, macro, complete, paperless, Path, absoluteOptions } = params
calculateHelpers(part) calculateHelpers(params)
draftTieShape(part, absoluteOptions.tipWidth, absoluteOptions.knotWidth) draftTieShape(params, absoluteOptions.tipWidth, absoluteOptions.knotWidth)
paths.seam.attributes.add('class', 'interfacing') paths.seam.attributes.add('class', 'interfacing')
// Complete pattern? // Complete pattern?
@ -61,7 +60,7 @@ function trayvonInterfacingTip(part) {
.attr('data-text-class', 'center') .attr('data-text-class', 'center')
} }
return part return params.part
} }
export const interfacingTail = { export const interfacingTail = {

View file

@ -7,7 +7,7 @@ import {
options, options,
} from './shared.mjs' } from './shared.mjs'
function trayvonLiningTail(part) { function trayvonLiningTail(params) {
const { const {
Path, Path,
Snippet, Snippet,
@ -21,10 +21,10 @@ function trayvonLiningTail(part) {
snippets, snippets,
store, store,
absoluteOptions, absoluteOptions,
} = part.shorthand() } = params
calculateHelpers(part) calculateHelpers(params)
draftTieShape(part, store.get('backTip') * 2.5, options.knotWidth * 2.5) draftTieShape(params, store.get('backTip') * 2.5, options.knotWidth * 2.5)
// Cut part short // Cut part short
points.cutRight = points.tipRight.shiftTowards(points.midRight, absoluteOptions.tipWidth * 2.5) points.cutRight = points.tipRight.shiftTowards(points.midRight, absoluteOptions.tipWidth * 2.5)
@ -57,10 +57,10 @@ function trayvonLiningTail(part) {
// Paperless? // Paperless?
if (paperless) tieShapeDimensions(part, true) if (paperless) tieShapeDimensions(part, true)
return part return params.part
} }
function trayvonLiningTip(part) { function trayvonLiningTip(params) {
const { const {
Path, Path,
Snippet, Snippet,
@ -72,10 +72,10 @@ function trayvonLiningTip(part) {
sa, sa,
snippets, snippets,
absoluteOptions, absoluteOptions,
} = part.shorthand() } = params
calculateHelpers(part) calculateHelpers(params)
draftTieShape(part, absoluteOptions.tipWidth * 2.5, absoluteOptions.knotWidth * 2.5) draftTieShape(params, absoluteOptions.tipWidth * 2.5, absoluteOptions.knotWidth * 2.5)
// Cut part short // Cut part short
points.cutRight = points.tipRight.shiftTowards(points.midRight, absoluteOptions.tipWidth * 2.5) points.cutRight = points.tipRight.shiftTowards(points.midRight, absoluteOptions.tipWidth * 2.5)
@ -111,7 +111,7 @@ function trayvonLiningTip(part) {
tieShapeDimensions(part, true) tieShapeDimensions(part, true)
} }
return part return params.part
} }
export const liningTail = { export const liningTail = {

View file

@ -1,8 +1,16 @@
import { pluginBundle } from '@freesewing/plugin-bundle' import { pluginBundle } from '@freesewing/plugin-bundle'
function trayvonFabricLoop(part) { function trayvonFabricLoop({
const { points, Point, paths, Path, complete, paperless, store, macro } = part.shorthand() points,
Point,
paths,
Path,
complete,
paperless,
store,
macro,
part,
}) {
points.topLeft = new Point(0, 0) points.topLeft = new Point(0, 0)
points.bottomRight = new Point(store.get('backTip') * 3.5, store.get('backTip')) points.bottomRight = new Point(store.get('backTip') * 3.5, store.get('backTip'))
points.topRight = new Point(points.bottomRight.x, points.topLeft.y) points.topRight = new Point(points.bottomRight.x, points.topLeft.y)

View file

@ -11,9 +11,7 @@ export const options = {
menu: 'style', menu: 'style',
}, },
} }
export const calculateHelpers = (part) => { export const calculateHelpers = ({ store, measurements, options, absoluteOptions }) => {
let { store, measurements, options, absoluteOptions } = part.shorthand()
let halfLength = let halfLength =
(measurements.hpsToWaistBack + measurements.waistToHips + measurements.neck / 2) * (measurements.hpsToWaistBack + measurements.waistToHips + measurements.neck / 2) *
(1 + options.lengthBonus) (1 + options.lengthBonus)
@ -24,9 +22,12 @@ export const calculateHelpers = (part) => {
store.set('backTip', backTip) store.set('backTip', backTip)
} }
export const draftTieShape = (part, tipWidth, knotWidth, notch = false) => { export const draftTieShape = (
let { points, Point, store, utils, paths, Path, macro, absoluteOptions } = part.shorthand() { points, Point, store, utils, paths, Path, macro, absoluteOptions },
tipWidth,
knotWidth,
notch = false
) => {
let hl = store.get('halfLength') let hl = store.get('halfLength')
let ht = tipWidth / 2 let ht = tipWidth / 2
let hk = knotWidth / 2 let hk = knotWidth / 2
@ -62,9 +63,7 @@ export const draftTieShape = (part, tipWidth, knotWidth, notch = false) => {
.close() .close()
} }
export const tieShapeDimensions = (part, lining = false) => { export const tieShapeDimensions = ({ points, macro, paths, Path }, lining = false) => {
let { points, macro, paths, Path } = part.shorthand()
macro('hd', { macro('hd', {
from: points.tipLeft, from: points.tipLeft,
to: points.tipRight, to: points.tipRight,
@ -100,8 +99,7 @@ export const tieShapeDimensions = (part, lining = false) => {
} }
} }
export const seamAllowance = (part, className) => { export const seamAllowance = ({ paths, Path, points, sa }, className) => {
let { paths, Path, points, sa } = part.shorthand()
paths.sa = new Path() paths.sa = new Path()
.move(points.tipLeft) .move(points.tipLeft)
.line(points.tip) .line(points.tip)