1
0
Fork 0

chore(sandy): Ported to v3

This commit is contained in:
joostdecock 2022-09-04 19:03:18 +02:00
parent d5ada5bbae
commit a56e20464d
8 changed files with 66 additions and 88 deletions

View file

@ -1,46 +0,0 @@
import pkg from '../package.json' assert { type: 'json' }
import configHelpers from '@freesewing/config-helpers'
const { version } = pkg
const { elastics, pctBasedOn } = configHelpers
export default {
name: 'sandy',
version: version,
design: 'Erica Alcusa Sáez',
code: ['Erica Alcusa Sáez', 'Joost De Cock'],
department: 'bottoms',
type: 'pattern',
difficulty: 3,
optionGroups: {
fit: ['waistbandPosition', 'waistbandShape'],
style: ['lengthBonus', 'circleRatio', 'waistbandWidth', 'waistbandOverlap', 'gathering'],
construction: ['seamlessFullCircle', 'hemWidth'],
},
measurements: ['waist', 'waistToFloor', 'waistToHips', 'hips'],
dependencies: {
waistband: 'skirt',
},
options: {
// Constants
minimumOverlap: 15, // Lower than this and we don't draw a button
// Bool
seamlessFullCircle: { bool: false },
// Percentages
waistbandWidth: { pct: 4, min: 1, max: 8, snap: elastics, ...pctBasedOn('waistToFloor') },
waistbandPosition: { pct: 50, min: 0, max: 100 },
lengthBonus: { pct: 50, min: 10, max: 100 },
circleRatio: { pct: 50, min: 20, max: 100 },
waistbandOverlap: { pct: 3, min: 0, max: 15 },
gathering: { pct: 0, min: 0, max: 200 },
hemWidth: { pct: 2, min: 1, max: 10 },
// Lists
waistbandShape: {
list: ['straight', 'curved'],
dflt: 'straight',
},
},
}

View file

@ -1,6 +1,6 @@
import draftRingSector from './shared' import { draftRingSector } from './shared.mjs'
export default function (part) { export function draftCurvedWaistband(part) {
/** /**
* The curved waistband is just a ring sector with external * The curved waistband is just a ring sector with external
* and intenal radius and angle calculated from measurements * and intenal radius and angle calculated from measurements

View file

@ -1,19 +1,13 @@
import freesewing from '@freesewing/core' import { Design } from '@freesewing/core'
import plugins from '@freesewing/plugin-bundle' import { data } from '../data.mjs'
import config from '../config' import { skirt } from './skirt.mjs'
// Parts import { waistband } from './waistband.mjs'
import draftSkirt from './skirt'
import draftWaistband from './waistband'
// Create design // Setup our new design
const Sandy = new freesewing.Design(config, plugins) const Sandy = new Design({
data,
// Attach draft methods to prototype parts: [skirt, waistband],
Sandy.prototype.draftSkirt = (part) => draftSkirt(part) })
Sandy.prototype.draftWaistband = (part) => draftWaistband(part)
// Named exports // Named exports
export { config, Sandy } export { skirt, waistband, Sandy }
// Default export
export default Sandy

View file

@ -1,4 +1,4 @@
const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { export const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => {
const { utils, Point, points, Path } = part.shorthand() const { utils, Point, points, Path } = part.shorthand()
const roundExtended = (radius, angle = 90) => { const roundExtended = (radius, angle = 90) => {
@ -103,5 +103,3 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => {
.curve(points.ex1CFlipped, points.ex2CFlipped, points.ex2Flipped) .curve(points.ex1CFlipped, points.ex2CFlipped, points.ex2Flipped)
.close() .close()
} }
export default draftRingSector

View file

@ -1,6 +1,9 @@
import draftRingSector from './shared' import { draftRingSector } from './shared.mjs'
import { pctBasedOn } from '@freesewing/core'
import { pluginBundle } from '@freesewing/plugin-bundle'
import { elastics } from '@freesewing/snapseries'
export default function (part) { function sandySkirt(part) {
const { const {
utils, utils,
store, store,
@ -208,3 +211,25 @@ export default function (part) {
return part return part
} }
export const skirt = {
name: 'sandy.skirt',
measurements: ['waist', 'waistToFloor', 'waistToHips', 'hips'],
plugins: pluginBundle,
options: {
minimumOverlap: 15, // Lower than this and we don't draw a button
seamlessFullCircle: { bool: false },
waistbandWidth: { pct: 4, min: 1, max: 8, snap: elastics, ...pctBasedOn('waistToFloor') },
waistbandPosition: { pct: 50, min: 0, max: 100 },
lengthBonus: { pct: 50, min: 10, max: 100 },
circleRatio: { pct: 50, min: 20, max: 100 },
waistbandOverlap: { pct: 3, min: 0, max: 15 },
gathering: { pct: 0, min: 0, max: 200 },
hemWidth: { pct: 2, min: 1, max: 10 },
waistbandShape: {
list: ['straight', 'curved'],
dflt: 'straight',
},
},
draft: sandySkirt,
}

View file

@ -1,4 +1,4 @@
export default function (part) { export function draftStraightWaistband(part) {
/** /**
* The straight waistband is just a rectangle with the width * The straight waistband is just a rectangle with the width
* of double the waistband width, since it will be folded * of double the waistband width, since it will be folded

View file

@ -1,9 +1,14 @@
import straightWaistband from './straight-waistband' import { draftStraightWaistband } from './straight-waistband.mjs'
import curvedWaistband from './curved-waistband' import { draftCurvedWaistband } from './curved-waistband.mjs'
export default (part) => { const sandyWaistband = (part) => {
const { options } = part.shorthand() const { options } = part.shorthand()
if (options.waistbandShape === 'curved') return curvedWaistband(part) if (options.waistbandShape === 'curved') return draftCurvedWaistband(part)
else return straightWaistband(part) else return draftStraightWaistband(part)
}
export const waistband = {
name: 'sandy.waistband',
draft: sandyWaistband,
} }

View file

@ -64,22 +64,24 @@ export const testPatternConfig = (Pattern) => {
// Config tests for non-utility patterns only // Config tests for non-utility patterns only
if (family !== 'utilities') { if (family !== 'utilities') {
it(` - 'design' should be set and be a string of reasonable length`, () => { it(` - 'design' should be set and be a string of reasonable length`, () => {
if (Array.isArray(meta.design)) { const people = Array.isArray(meta.design)
for (const person of meta.design) { ? meta.design
expect(typeof person).to.equal('string') : [ meta.design ]
expect(person.length > 2).to.be.true for (const person of people) {
expect(person.length < 80).to.be.true expect(typeof person).to.equal('string')
} expect(person.length > 2).to.be.true
} else { expect(person.length < 80).to.be.true
expect(typeof meta.design).to.equal('string')
expect(meta.design.length > 2).to.be.true
expect(meta.design.length < 80).to.be.true
} }
}) })
it(` - 'code' should be set and be a string of reasonable length`, () => { it(` - 'code' should be set and be a string of reasonable length`, () => {
expect(typeof meta.code).to.equal('string') const people = Array.isArray(meta.code)
expect(meta.code.length > 2).to.be.true ? meta.design
expect(meta.code.length < 80).to.be.true : [ meta.design ]
for (const person of people) {
expect(typeof person).to.equal('string')
expect(person.length > 2).to.be.true
expect(person.length < 80).to.be.true
}
}) })
it(` - 'department' should be set and be a string of reasonable length`, () => { it(` - 'department' should be set and be a string of reasonable length`, () => {
expect(typeof meta.code).to.equal('string') expect(typeof meta.code).to.equal('string')