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

View file

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

View file

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

View file

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