1
0
Fork 0

chore(holmes): Port to v3 stage 2

This commit is contained in:
joostdecock 2022-09-11 14:31:50 +02:00
parent 0776ccbd0e
commit 1cd21a38b8
4 changed files with 95 additions and 89 deletions

View file

@ -1,22 +1,21 @@
import { pluginBundle } from '@freesewing/plugin-bundle'
function draftHolmesEar (part) {
let {
Point,
points,
Path,
paths,
measurements,
options,
complete,
sa,
snippets,
Snippet,
paperless,
macro,
absoluteOptions,
} = part.shorthand()
function draftHolmesEar({
Point,
points,
Path,
paths,
measurements,
options,
complete,
sa,
snippets,
Snippet,
paperless,
macro,
absoluteOptions,
part,
}) {
// Design pattern here
let headCircumference = measurements.head + absoluteOptions.headEase
let earFlapLength = ((options.lengthRatio * headCircumference) / 2) * options.earLength
@ -32,9 +31,8 @@ function draftHolmesEar (part) {
.move(points.bottom)
.curve(points.bottomC, points.topC, points.top)
.curve(points.topCFlipped, points.bottomCFlipped, points.bottomFlipped)
.setRender(false)
paths.hemBase = new Path().move(points.bottomFlipped).line(points.bottom)
.setRender(false)
.setRender(false)
paths.hemBase = new Path().move(points.bottomFlipped).line(points.bottom).setRender(false)
paths.seam = paths.saBase.join(paths.hemBase).close()
// Complete?
if (complete) {
@ -83,20 +81,24 @@ function draftHolmesEar (part) {
export const ear = {
name: 'holmes.ear',
measurements: [ 'head' ],
measurements: ['head'],
options: {
headEase: { pct: 3, min: 0, max: 9,
headEase: {
pct: 3,
min: 0,
max: 9,
snap: {
metric: [6, 13, 19, 25, 32, 38, 44, 50],
imperial: [6.35, 12.7, 19.05, 25.4, 31.75, 38.1, 44.45, 50.8],
},
toAbs: (pct, { measurements }) => measurements.head * pct,
menu: 'fit' },
menu: 'fit',
},
lengthRatio: { pct: 55, min: 40, max: 60, menu: 'style' },
earLength: { pct: 100, min: 80, max: 150, menu: 'style' },
earWidth: { pct: 100, min: 80, max: 150, menu: 'style' },
buttonhole: { bool: false },
},
plugins: [ pluginBundle ],
plugins: [pluginBundle],
draft: draftHolmesEar,
}

View file

@ -1,23 +1,20 @@
import { pluginBundle } from '@freesewing/plugin-bundle'
import { pluginGore } from '@freesewing/plugin-gore'
function draftHolmesGore (part) {
let {
Point,
points,
Path,
paths,
measurements,
options,
macro,
complete,
sa,
paperless,
absoluteOptions,
} = part.shorthand()
// Design pattern here
function draftHolmesGore({
Point,
points,
Path,
paths,
measurements,
options,
macro,
complete,
sa,
paperless,
absoluteOptions,
part,
}) {
//Radius of the head
let headCircumference = measurements.head + absoluteOptions.headEase
let headRadius = headCircumference / 2 / Math.PI
@ -87,18 +84,22 @@ function draftHolmesGore (part) {
export const gore = {
name: 'holmes.gore',
measurements: [ 'head' ],
measurements: ['head'],
options: {
headEase: { pct: 3, min: 0, max: 9,
headEase: {
pct: 3,
min: 0,
max: 9,
snap: {
metric: [6, 13, 19, 25, 32, 38, 44, 50],
imperial: [6.35, 12.7, 19.05, 25.4, 31.75, 38.1, 44.45, 50.8],
},
toAbs: (pct, { measurements }) => measurements.head * pct,
menu: 'fit' },
menu: 'fit',
},
lengthRatio: { pct: 55, min: 40, max: 60, menu: 'style' },
gores: { count: 6, min: 4, max: 20, menu: 'style' },
},
plugins: [ pluginBundle, pluginGore ],
plugins: [pluginBundle, pluginGore],
draft: draftHolmesGore,
}

View file

@ -9,7 +9,7 @@ import { ear } from './ear.mjs'
// Create new design
const Holmes = new Design({
data,
parts: [ gore, visor, ear ],
parts: [gore, visor, ear],
})
// Named exports

View file

@ -1,21 +1,20 @@
import { pluginBundle } from '@freesewing/plugin-bundle'
import { pctBasedOn } from '@freesewing/core'
function draftHolmesVisor (part) {
let {
Point,
points,
Path,
paths,
measurements,
options,
complete,
sa,
paperless,
macro,
absoluteOptions,
} = part.shorthand()
function draftHolmesVisor({
Point,
points,
Path,
paths,
measurements,
options,
complete,
sa,
paperless,
macro,
absoluteOptions,
part,
}) {
let headCircumference = measurements.head + absoluteOptions.headEase
let headRadius = headCircumference / 2 / Math.PI
let visorRadius = headRadius / Math.sin((options.visorAngle * Math.PI) / 180)
@ -49,34 +48,35 @@ function draftHolmesVisor (part) {
)
points.ex1CFlipped = points.ex1C.flipX()
points.ex2CFlipped = points.ex2C.flipX()
paths.saInner = new Path ()
.move(points.in2)
.curve(points.in2C, points.in1C, points.in1)
.curve(points.in1CFlipped, points.in2CFlipped, points.in2Flipped)
.setRender(false)
paths.saOuter = new Path()
.move(points.in2Flipped)
.curve(points.ex2CFlipped, points.ex1CFlipped, points.ex1)
.curve(points.ex1C, points.ex2C, points.in2)
.setRender(false)
paths.seam = paths.saOuter.join(paths.saInner).close()
paths.saInner = new Path()
.move(points.in2)
.curve(points.in2C, points.in1C, points.in1)
.curve(points.in1CFlipped, points.in2CFlipped, points.in2Flipped)
.setRender(false)
paths.saOuter = new Path()
.move(points.in2Flipped)
.curve(points.ex2CFlipped, points.ex1CFlipped, points.ex1)
.curve(points.ex1C, points.ex2C, points.in2)
.setRender(false)
paths.seam = paths.saOuter.join(paths.saInner).close()
// Complete?
if (complete) {
macro('grainline', { from: points.in1, to: points.ex1 })
macro('title', { at: points.ex1.shift(45, 20), nr: 2, title: 'visor', scale: 0.4 })
if (sa) {
points.sa1 = new Point(points.in2.x + sa, paths.saInner.offset(sa*2).start().y)
points.sa2 = points.sa1.flipX(points.in1)
paths.sa = paths.saOuter.offset(sa)
.line(points.sa1)
.join(paths .saInner.offset(sa * 2))
.line(points.sa2)
.close()
.attr('class', 'fabric sa')
points.sa1 = new Point(points.in2.x + sa, paths.saInner.offset(sa * 2).start().y)
points.sa2 = points.sa1.flipX(points.in1)
paths.sa = paths.saOuter
.offset(sa)
.line(points.sa1)
.join(paths.saInner.offset(sa * 2))
.line(points.sa2)
.close()
.attr('class', 'fabric sa')
}
// Paperless?
@ -103,20 +103,23 @@ paths.seam = paths.saOuter.join(paths.saInner).close()
export const visor = {
name: 'holmes.visor',
measurements: [ 'head' ],
measurements: ['head'],
options: {
headEase: { pct: 3, min: 0, max: 9,
headEase: {
pct: 3,
min: 0,
max: 9,
snap: {
metric: [6, 13, 19, 25, 32, 38, 44, 50],
imperial: [6.35, 12.7, 19.05, 25.4, 31.75, 38.1, 44.45, 50.8],
},
toAbs: (pct, { measurements }) => measurements.head * pct,
menu: 'fit' },
menu: 'fit',
},
visorAngle: { deg: 45, min: 10, max: 90, menu: 'style' },
visorWidth: { pct: 5, min: 1, max: 17, snap: 5, ...pctBasedOn('head'),
menu: 'style' },
visorWidth: { pct: 5, min: 1, max: 17, snap: 5, ...pctBasedOn('head'), menu: 'style' },
visorLength: { pct: 100, min: 80, max: 150, menu: 'advanced' },
},
plugins: [ pluginBundle ],
plugins: [pluginBundle],
draft: draftHolmesVisor,
}