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
* and intenal radius and angle calculated from measurements

View file

@ -1,19 +1,13 @@
import freesewing from '@freesewing/core'
import plugins from '@freesewing/plugin-bundle'
import config from '../config'
// Parts
import draftSkirt from './skirt'
import draftWaistband from './waistband'
import { Design } from '@freesewing/core'
import { data } from '../data.mjs'
import { skirt } from './skirt.mjs'
import { waistband } from './waistband.mjs'
// Create design
const Sandy = new freesewing.Design(config, plugins)
// Attach draft methods to prototype
Sandy.prototype.draftSkirt = (part) => draftSkirt(part)
Sandy.prototype.draftWaistband = (part) => draftWaistband(part)
// Setup our new design
const Sandy = new Design({
data,
parts: [skirt, waistband],
})
// Named exports
export { config, Sandy }
// Default export
export default Sandy
export { skirt, waistband, 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 roundExtended = (radius, angle = 90) => {
@ -103,5 +103,3 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => {
.curve(points.ex1CFlipped, points.ex2CFlipped, points.ex2Flipped)
.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 {
utils,
store,
@ -208,3 +211,25 @@ export default function (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
* of double the waistband width, since it will be folded

View file

@ -1,9 +1,14 @@
import straightWaistband from './straight-waistband'
import curvedWaistband from './curved-waistband'
import { draftStraightWaistband } from './straight-waistband.mjs'
import { draftCurvedWaistband } from './curved-waistband.mjs'
export default (part) => {
const sandyWaistband = (part) => {
const { options } = part.shorthand()
if (options.waistbandShape === 'curved') return curvedWaistband(part)
else return straightWaistband(part)
if (options.waistbandShape === 'curved') return draftCurvedWaistband(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
if (family !== 'utilities') {
it(` - 'design' should be set and be a string of reasonable length`, () => {
if (Array.isArray(meta.design)) {
for (const person of meta.design) {
expect(typeof person).to.equal('string')
expect(person.length > 2).to.be.true
expect(person.length < 80).to.be.true
}
} else {
expect(typeof meta.design).to.equal('string')
expect(meta.design.length > 2).to.be.true
expect(meta.design.length < 80).to.be.true
const people = Array.isArray(meta.design)
? meta.design
: [ 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(` - 'code' should be set and be a string of reasonable length`, () => {
expect(typeof meta.code).to.equal('string')
expect(meta.code.length > 2).to.be.true
expect(meta.code.length < 80).to.be.true
const people = Array.isArray(meta.code)
? meta.design
: [ 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`, () => {
expect(typeof meta.code).to.equal('string')