chore(albert): Ported to v3
This commit is contained in:
parent
3402b91fdd
commit
e55122da44
11 changed files with 473 additions and 459 deletions
|
@ -14,7 +14,7 @@ const banner = `/**
|
||||||
const options = {
|
const options = {
|
||||||
banner: { js: banner },
|
banner: { js: banner },
|
||||||
bundle: true,
|
bundle: true,
|
||||||
entryPoints: ['src/index.js'],
|
entryPoints: ['src/index.mjs'],
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
outfile: 'dist/index.mjs',
|
outfile: 'dist/index.mjs',
|
||||||
external: ["@freesewing"],
|
external: ["@freesewing"],
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
import pkg from '../package.json' assert { type: 'json' }
|
|
||||||
const { version } = pkg
|
|
||||||
|
|
||||||
export default {
|
|
||||||
version,
|
|
||||||
name: 'albert',
|
|
||||||
design: 'Wouter Van Wageningen',
|
|
||||||
code: 'Wouter Van Wageningen',
|
|
||||||
department: 'accessories',
|
|
||||||
type: 'pattern',
|
|
||||||
difficulty: 2,
|
|
||||||
optionGroups: {
|
|
||||||
fit: ['backOpening', 'chestDepth'],
|
|
||||||
style: ['lengthBonus', 'bibLength', 'bibWidth', 'strapWidth'],
|
|
||||||
},
|
|
||||||
measurements: ['chest', 'waist', 'hips', 'hpsToWaistBack', 'waistToKnee'],
|
|
||||||
dependencies: {},
|
|
||||||
inject: {},
|
|
||||||
hide: [],
|
|
||||||
parts: ['front', 'strap', 'pocket'],
|
|
||||||
options: {
|
|
||||||
backOpening: { pct: 10, min: 0, max: 25 },
|
|
||||||
lengthBonus: { pct: 0, min: -20, max: 25 },
|
|
||||||
chestDepth: { pct: 22, min: 15, max: 90 },
|
|
||||||
bibLength: { pct: 75, min: 0, max: 90 },
|
|
||||||
bibWidth: { pct: 100, min: 50, max: 125 },
|
|
||||||
strapWidth: { pct: 60, min: 20, max: 100 },
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -38,7 +38,7 @@
|
||||||
"vbuild": "VERBOSE=1 node --experimental-json-modules build.mjs",
|
"vbuild": "VERBOSE=1 node --experimental-json-modules build.mjs",
|
||||||
"lab": "cd ../../sites/lab && yarn start",
|
"lab": "cd ../../sites/lab && yarn start",
|
||||||
"tips": "node ../../scripts/help.mjs",
|
"tips": "node ../../scripts/help.mjs",
|
||||||
"prettier": "npx prettier --write 'src/*.js' 'config/*.js'",
|
"prettier": "npx prettier --write 'src/*.mjs' 'tests/*.mjs'",
|
||||||
"testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js",
|
"testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js",
|
||||||
"cibuild_step5": "node --experimental-json-modules build.mjs"
|
"cibuild_step5": "node --experimental-json-modules build.mjs"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,185 +0,0 @@
|
||||||
export default function (part) {
|
|
||||||
let {
|
|
||||||
options,
|
|
||||||
measurements,
|
|
||||||
Point,
|
|
||||||
Path,
|
|
||||||
points,
|
|
||||||
paths,
|
|
||||||
Snippet,
|
|
||||||
snippets,
|
|
||||||
complete,
|
|
||||||
sa,
|
|
||||||
paperless,
|
|
||||||
macro,
|
|
||||||
} = part.shorthand()
|
|
||||||
|
|
||||||
let chestWidth = measurements.chest / 4
|
|
||||||
let bibWidth = chestWidth * options.bibWidth
|
|
||||||
let bibLength = measurements.hpsToWaistBack * options.bibLength
|
|
||||||
let apronLength =
|
|
||||||
measurements.hpsToWaistBack * options.bibLength +
|
|
||||||
measurements.waistToKnee * (1 + options.lengthBonus)
|
|
||||||
/*
|
|
||||||
let apronWidth =
|
|
||||||
Math.max(measurements.hips, measurements.waist) *
|
|
||||||
(1 - options.backOpening)
|
|
||||||
*/
|
|
||||||
let apronWidth = measurements.waist * (1 - options.backOpening)
|
|
||||||
let strapWidth = (measurements.hpsToWaistBack * options.strapWidth) / 8
|
|
||||||
let hemWidth = 3 * sa
|
|
||||||
let pocketSize = apronLength / 4
|
|
||||||
|
|
||||||
points.topLeft = new Point(0, 0)
|
|
||||||
points.topLeftHem = points.topLeft.shift(270, hemWidth)
|
|
||||||
points.bottomLeftHem = points.topLeftHem.shift(270, apronLength)
|
|
||||||
points.waistLeft = points.topLeftHem.shift(270, bibLength)
|
|
||||||
points.bottomLeft = points.bottomLeftHem.shift(270, hemWidth)
|
|
||||||
points.topRight = points.topLeft.shift(0, bibWidth / 2)
|
|
||||||
points.topRightHem = points.topLeftHem.shift(0, bibWidth / 2)
|
|
||||||
points.bottomRightHem = points.bottomLeftHem.shift(0, apronWidth / 2)
|
|
||||||
points.bottomRight = points.bottomLeft.shift(0, apronWidth / 2)
|
|
||||||
points.topRightBack = points.bottomRightHem.shift(90, apronLength - bibLength)
|
|
||||||
points.topRightBackCPfront = points.topRightBack.shift(180, (apronWidth - bibWidth) / 2 / 1.5)
|
|
||||||
points.topRightCPdown = points.topRightHem.shift(
|
|
||||||
270,
|
|
||||||
(measurements.hpsToWaistBack * options.bibLength) / 4
|
|
||||||
)
|
|
||||||
|
|
||||||
points.topCOF = points.topLeft.shift(270, apronLength / 5)
|
|
||||||
points.bottomCOF = points.bottomLeft.shift(90, apronLength / 5)
|
|
||||||
|
|
||||||
points.pocketLeftTop = points.waistLeft.shift(270, hemWidth)
|
|
||||||
points.pocketRightTop = points.pocketLeftTop.shift(0, pocketSize)
|
|
||||||
points.pocketLeftBottom = points.pocketLeftTop.shift(270, pocketSize)
|
|
||||||
points.pocketRightBottom = points.pocketLeftBottom.shift(0, pocketSize)
|
|
||||||
|
|
||||||
points.crossBoxTo1 = new Point(points.topRightHem.x - strapWidth, points.topRightHem.y + hemWidth)
|
|
||||||
points.crossBoxTo2 = new Point(
|
|
||||||
points.topRightBack.x - strapWidth,
|
|
||||||
points.topRightBack.y + hemWidth
|
|
||||||
)
|
|
||||||
|
|
||||||
paths.rightHem = new Path()
|
|
||||||
.move(points.bottomRight)
|
|
||||||
.line(points.topRightBack)
|
|
||||||
.curve(points.topRightBackCPfront, points.topRightCPdown, points.topRightHem)
|
|
||||||
.line(points.topRight)
|
|
||||||
.attr('class', 'various dashed')
|
|
||||||
.attr('data-text', 'narrow hem')
|
|
||||||
.attr('data-text-class', 'text-xs center')
|
|
||||||
|
|
||||||
paths.pocket = new Path()
|
|
||||||
.move(points.pocketLeftBottom)
|
|
||||||
.line(points.pocketLeftTop)
|
|
||||||
.line(points.pocketRightTop)
|
|
||||||
.line(points.pocketRightBottom)
|
|
||||||
.line(points.pocketLeftBottom)
|
|
||||||
.attr('class', 'lining dotted stroke-sm')
|
|
||||||
.attr('data-text', 'pocket')
|
|
||||||
.attr('data-text-class', 'text-xs center')
|
|
||||||
|
|
||||||
paths.right = paths.rightHem.offset(sa)
|
|
||||||
|
|
||||||
paths.seam = new Path()
|
|
||||||
.move(points.bottomLeft)
|
|
||||||
.join(paths.right)
|
|
||||||
.line(points.topLeft)
|
|
||||||
.close()
|
|
||||||
.attr('class', 'fabric')
|
|
||||||
|
|
||||||
paths.complete = paths.seam.clone().line(points.bottomLeft).close()
|
|
||||||
|
|
||||||
paths.topHem = new Path()
|
|
||||||
.move(points.topLeftHem)
|
|
||||||
.line(points.topRightHem.shift(0, sa))
|
|
||||||
.attr('class', 'various dashed')
|
|
||||||
.attr('data-text', 'hem')
|
|
||||||
.attr('data-text-class', 'text-xs center')
|
|
||||||
paths.bottomHem = new Path()
|
|
||||||
.move(points.bottomLeftHem)
|
|
||||||
.line(points.bottomRightHem.shift(0, sa))
|
|
||||||
.attr('class', 'various dashed')
|
|
||||||
.attr('data-text', 'hem')
|
|
||||||
.attr('data-text-class', 'text-xs center')
|
|
||||||
|
|
||||||
// Complete?
|
|
||||||
if (complete) {
|
|
||||||
points.logo = points.topRightBack.shiftFractionTowards(points.pocketRightBottom, 0.5)
|
|
||||||
snippets.logo = new Snippet('logo', points.logo)
|
|
||||||
points.title = points.logo.shift(-90, 100)
|
|
||||||
macro('title', {
|
|
||||||
nr: 1,
|
|
||||||
at: points.title,
|
|
||||||
title: 'Front',
|
|
||||||
})
|
|
||||||
|
|
||||||
points.scaleboxAnchor = points.pocketLeftBottom.shiftFractionTowards(points.bottomRight, 0.5)
|
|
||||||
macro('scalebox', { at: points.scaleboxAnchor })
|
|
||||||
|
|
||||||
macro('crossBox', {
|
|
||||||
from: points.topRightHem,
|
|
||||||
to: points.crossBoxTo1,
|
|
||||||
})
|
|
||||||
macro('crossBox', {
|
|
||||||
from: points.topRightBack,
|
|
||||||
to: points.crossBoxTo2,
|
|
||||||
text: 'attachment',
|
|
||||||
})
|
|
||||||
|
|
||||||
if (sa) {
|
|
||||||
paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
|
|
||||||
}
|
|
||||||
|
|
||||||
macro('cutonfold', {
|
|
||||||
from: points.topCOF,
|
|
||||||
to: points.bottomCOF,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Paperless?
|
|
||||||
if (paperless) {
|
|
||||||
macro('hd', {
|
|
||||||
from: points.bottomLeft,
|
|
||||||
to: points.bottomRight,
|
|
||||||
y: points.bottomLeft.y + sa + 15,
|
|
||||||
})
|
|
||||||
macro('hd', {
|
|
||||||
from: points.topLeft,
|
|
||||||
to: points.topRight,
|
|
||||||
y: points.topLeft.y - sa - 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.bottomLeft,
|
|
||||||
to: points.topLeft,
|
|
||||||
x: points.topLeft.x - sa - 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.bottomRight,
|
|
||||||
to: points.topRightBack,
|
|
||||||
x: points.topRightBack.x + sa + 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.topRightBack,
|
|
||||||
to: points.topRight,
|
|
||||||
x: points.topRightBack.x + sa + 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.topLeft,
|
|
||||||
to: points.topLeftHem,
|
|
||||||
x: points.topLeftHem.x + sa + 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.topLeftHem,
|
|
||||||
to: points.bottomLeftHem,
|
|
||||||
x: points.topLeftHem.x + sa + 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.bottomLeftHem,
|
|
||||||
to: points.bottomLeft,
|
|
||||||
x: points.bottomLeftHem.x + sa + 15,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return part
|
|
||||||
}
|
|
202
designs/albert/src/front.mjs
Normal file
202
designs/albert/src/front.mjs
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
export const bibLength = { pct: 75, min: 0, max: 90, menu: 'style' }
|
||||||
|
export const lengthBonus = { pct: 0, min: -20, max: 25, menu: 'style' }
|
||||||
|
export const backOpening = { pct: 10, min: 0, max: 25, menu: 'fit' }
|
||||||
|
export const bibWidth = { pct: 100, min: 50, max: 125, menu: 'style' }
|
||||||
|
export const strapWidth = { pct: 60, min: 20, max: 100, menu: 'style' }
|
||||||
|
|
||||||
|
export const front = {
|
||||||
|
name: 'albert.front',
|
||||||
|
measurements: [ 'chest', 'hpsToWaistBack', 'waist', 'waistToKnee' ],
|
||||||
|
options: {
|
||||||
|
backOpening,
|
||||||
|
bibWidth,
|
||||||
|
strapWidth,
|
||||||
|
bibLength,
|
||||||
|
lengthBonus,
|
||||||
|
},
|
||||||
|
draft: function (part) {
|
||||||
|
const {
|
||||||
|
options,
|
||||||
|
measurements,
|
||||||
|
Point,
|
||||||
|
Path,
|
||||||
|
points,
|
||||||
|
paths,
|
||||||
|
Snippet,
|
||||||
|
snippets,
|
||||||
|
complete,
|
||||||
|
sa,
|
||||||
|
paperless,
|
||||||
|
macro,
|
||||||
|
} = part.shorthand()
|
||||||
|
|
||||||
|
let chestWidth = measurements.chest / 4
|
||||||
|
let bibWidth = chestWidth * options.bibWidth
|
||||||
|
let bibLength = measurements.hpsToWaistBack * options.bibLength
|
||||||
|
let apronLength =
|
||||||
|
measurements.hpsToWaistBack * options.bibLength +
|
||||||
|
measurements.waistToKnee * (1 + options.lengthBonus)
|
||||||
|
/*
|
||||||
|
let apronWidth =
|
||||||
|
Math.max(measurements.hips, measurements.waist) *
|
||||||
|
(1 - options.backOpening)
|
||||||
|
*/
|
||||||
|
let apronWidth = measurements.waist * (1 - options.backOpening)
|
||||||
|
let strapWidth = (measurements.hpsToWaistBack * options.strapWidth) / 8
|
||||||
|
let hemWidth = 3 * sa
|
||||||
|
let pocketSize = apronLength / 4
|
||||||
|
|
||||||
|
points.topLeft = new Point(0, 0)
|
||||||
|
points.topLeftHem = points.topLeft.shift(270, hemWidth)
|
||||||
|
points.bottomLeftHem = points.topLeftHem.shift(270, apronLength)
|
||||||
|
points.waistLeft = points.topLeftHem.shift(270, bibLength)
|
||||||
|
points.bottomLeft = points.bottomLeftHem.shift(270, hemWidth)
|
||||||
|
points.topRight = points.topLeft.shift(0, bibWidth / 2)
|
||||||
|
points.topRightHem = points.topLeftHem.shift(0, bibWidth / 2)
|
||||||
|
points.bottomRightHem = points.bottomLeftHem.shift(0, apronWidth / 2)
|
||||||
|
points.bottomRight = points.bottomLeft.shift(0, apronWidth / 2)
|
||||||
|
points.topRightBack = points.bottomRightHem.shift(90, apronLength - bibLength)
|
||||||
|
points.topRightBackCPfront = points.topRightBack.shift(180, (apronWidth - bibWidth) / 2 / 1.5)
|
||||||
|
points.topRightCPdown = points.topRightHem.shift(
|
||||||
|
270,
|
||||||
|
(measurements.hpsToWaistBack * options.bibLength) / 4
|
||||||
|
)
|
||||||
|
|
||||||
|
points.topCOF = points.topLeft.shift(270, apronLength / 5)
|
||||||
|
points.bottomCOF = points.bottomLeft.shift(90, apronLength / 5)
|
||||||
|
|
||||||
|
points.pocketLeftTop = points.waistLeft.shift(270, hemWidth)
|
||||||
|
points.pocketRightTop = points.pocketLeftTop.shift(0, pocketSize)
|
||||||
|
points.pocketLeftBottom = points.pocketLeftTop.shift(270, pocketSize)
|
||||||
|
points.pocketRightBottom = points.pocketLeftBottom.shift(0, pocketSize)
|
||||||
|
|
||||||
|
points.crossBoxTo1 = new Point(points.topRightHem.x - strapWidth, points.topRightHem.y + hemWidth)
|
||||||
|
points.crossBoxTo2 = new Point(
|
||||||
|
points.topRightBack.x - strapWidth,
|
||||||
|
points.topRightBack.y + hemWidth
|
||||||
|
)
|
||||||
|
|
||||||
|
paths.rightHem = new Path()
|
||||||
|
.move(points.bottomRight)
|
||||||
|
.line(points.topRightBack)
|
||||||
|
.curve(points.topRightBackCPfront, points.topRightCPdown, points.topRightHem)
|
||||||
|
.line(points.topRight)
|
||||||
|
.attr('class', 'various dashed')
|
||||||
|
.attr('data-text', 'narrow hem')
|
||||||
|
.attr('data-text-class', 'text-xs center')
|
||||||
|
|
||||||
|
paths.pocket = new Path()
|
||||||
|
.move(points.pocketLeftBottom)
|
||||||
|
.line(points.pocketLeftTop)
|
||||||
|
.line(points.pocketRightTop)
|
||||||
|
.line(points.pocketRightBottom)
|
||||||
|
.line(points.pocketLeftBottom)
|
||||||
|
.attr('class', 'lining dotted stroke-sm')
|
||||||
|
.attr('data-text', 'pocket')
|
||||||
|
.attr('data-text-class', 'text-xs center')
|
||||||
|
|
||||||
|
paths.right = paths.rightHem.offset(sa)
|
||||||
|
|
||||||
|
paths.seam = new Path()
|
||||||
|
.move(points.bottomLeft)
|
||||||
|
.join(paths.right)
|
||||||
|
.line(points.topLeft)
|
||||||
|
.close()
|
||||||
|
.attr('class', 'fabric')
|
||||||
|
|
||||||
|
paths.complete = paths.seam.clone().line(points.bottomLeft).close()
|
||||||
|
|
||||||
|
paths.topHem = new Path()
|
||||||
|
.move(points.topLeftHem)
|
||||||
|
.line(points.topRightHem.shift(0, sa))
|
||||||
|
.attr('class', 'various dashed')
|
||||||
|
.attr('data-text', 'hem')
|
||||||
|
.attr('data-text-class', 'text-xs center')
|
||||||
|
paths.bottomHem = new Path()
|
||||||
|
.move(points.bottomLeftHem)
|
||||||
|
.line(points.bottomRightHem.shift(0, sa))
|
||||||
|
.attr('class', 'various dashed')
|
||||||
|
.attr('data-text', 'hem')
|
||||||
|
.attr('data-text-class', 'text-xs center')
|
||||||
|
|
||||||
|
// Complete?
|
||||||
|
if (complete) {
|
||||||
|
points.logo = points.topRightBack.shiftFractionTowards(points.pocketRightBottom, 0.5)
|
||||||
|
snippets.logo = new Snippet('logo', points.logo)
|
||||||
|
points.title = points.logo.shift(-90, 100)
|
||||||
|
macro('title', {
|
||||||
|
nr: 1,
|
||||||
|
at: points.title,
|
||||||
|
title: 'Front',
|
||||||
|
})
|
||||||
|
|
||||||
|
points.scaleboxAnchor = points.pocketLeftBottom.shiftFractionTowards(points.bottomRight, 0.5)
|
||||||
|
macro('scalebox', { at: points.scaleboxAnchor })
|
||||||
|
|
||||||
|
macro('crossBox', {
|
||||||
|
from: points.topRightHem,
|
||||||
|
to: points.crossBoxTo1,
|
||||||
|
})
|
||||||
|
macro('crossBox', {
|
||||||
|
from: points.topRightBack,
|
||||||
|
to: points.crossBoxTo2,
|
||||||
|
text: 'attachment',
|
||||||
|
})
|
||||||
|
|
||||||
|
if (sa) {
|
||||||
|
paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
|
||||||
|
}
|
||||||
|
|
||||||
|
macro('cutonfold', {
|
||||||
|
from: points.topCOF,
|
||||||
|
to: points.bottomCOF,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paperless?
|
||||||
|
if (paperless) {
|
||||||
|
macro('hd', {
|
||||||
|
from: points.bottomLeft,
|
||||||
|
to: points.bottomRight,
|
||||||
|
y: points.bottomLeft.y + sa + 15,
|
||||||
|
})
|
||||||
|
macro('hd', {
|
||||||
|
from: points.topLeft,
|
||||||
|
to: points.topRight,
|
||||||
|
y: points.topLeft.y - sa - 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.bottomLeft,
|
||||||
|
to: points.topLeft,
|
||||||
|
x: points.topLeft.x - sa - 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.bottomRight,
|
||||||
|
to: points.topRightBack,
|
||||||
|
x: points.topRightBack.x + sa + 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.topRightBack,
|
||||||
|
to: points.topRight,
|
||||||
|
x: points.topRightBack.x + sa + 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.topLeft,
|
||||||
|
to: points.topLeftHem,
|
||||||
|
x: points.topLeftHem.x + sa + 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.topLeftHem,
|
||||||
|
to: points.bottomLeftHem,
|
||||||
|
x: points.topLeftHem.x + sa + 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.bottomLeftHem,
|
||||||
|
to: points.bottomLeft,
|
||||||
|
x: points.bottomLeftHem.x + sa + 15,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return part
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,18 @@
|
||||||
import freesewing from '@freesewing/core'
|
// FreeSewing Design constructor
|
||||||
import plugins from '@freesewing/plugin-bundle'
|
import { Design } from '@freesewing/core'
|
||||||
import config from '../config'
|
// FreeSewing Plugins
|
||||||
import draftFront from './front'
|
import { pluginBundle } from '@freesewing/plugin-bundle'
|
||||||
import draftStrap from './strap'
|
// Design parts
|
||||||
import draftPocket from './pocket'
|
import { front } from './front.mjs'
|
||||||
|
import { pocket } from './pocket.mjs'
|
||||||
|
import { strap } from './strap.mjs'
|
||||||
|
// Get name & version from package.json
|
||||||
|
import { name, version } from '../package.json'
|
||||||
|
|
||||||
|
// crossbox macro
|
||||||
const crossBox = {
|
const crossBox = {
|
||||||
name: 'crossbox',
|
name: 'crossbox',
|
||||||
version: config.version,
|
version,
|
||||||
macros: {
|
macros: {
|
||||||
crossBox: function (so) {
|
crossBox: function (so) {
|
||||||
let id = this.getId()
|
let id = this.getId()
|
||||||
|
@ -62,16 +67,17 @@ const crossBox = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new design
|
|
||||||
const Albert = new freesewing.Design(config, [plugins, crossBox])
|
|
||||||
|
|
||||||
// Attach the draft methods to the prototype
|
// Setup our new design
|
||||||
Albert.prototype.draftFront = draftFront
|
const Albert = new Design({
|
||||||
Albert.prototype.draftStrap = draftStrap
|
name,
|
||||||
Albert.prototype.draftPocket = draftPocket
|
version,
|
||||||
|
parts: [ front, pocket, strap ],
|
||||||
|
plugins: [ pluginBundle, crossBox ]
|
||||||
|
})
|
||||||
|
|
||||||
// Named exports
|
// Named exports
|
||||||
export { config, Albert }
|
export { front, pocket, strap, Albert }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Default export
|
|
||||||
export default Albert
|
|
|
@ -1,85 +0,0 @@
|
||||||
export default function (part) {
|
|
||||||
let {
|
|
||||||
options,
|
|
||||||
measurements,
|
|
||||||
Point,
|
|
||||||
Path,
|
|
||||||
points,
|
|
||||||
paths,
|
|
||||||
Snippet,
|
|
||||||
snippets,
|
|
||||||
complete,
|
|
||||||
sa,
|
|
||||||
paperless,
|
|
||||||
macro,
|
|
||||||
} = part.shorthand()
|
|
||||||
|
|
||||||
let apronLength =
|
|
||||||
measurements.hpsToWaistBack * options.bibLength +
|
|
||||||
measurements.waistToKnee * (1 + options.lengthBonus)
|
|
||||||
let pocketSize = apronLength / 4
|
|
||||||
let hemWidth = 3 * sa
|
|
||||||
|
|
||||||
points.topLeft = new Point(0, 0)
|
|
||||||
points.topRight = new Point(pocketSize, 0)
|
|
||||||
points.topLeftHem = points.topLeft.shift(270, hemWidth)
|
|
||||||
points.topRightHem = points.topRight.shift(270, hemWidth)
|
|
||||||
points.bottomLeft = points.topLeftHem.shift(270, pocketSize)
|
|
||||||
points.bottomRight = points.topRightHem.shift(270, pocketSize)
|
|
||||||
|
|
||||||
points.topCOF = points.topLeft.shift(270, pocketSize / 5)
|
|
||||||
points.bottomCOF = points.bottomLeft.shift(90, pocketSize / 5)
|
|
||||||
|
|
||||||
paths.seam = new Path()
|
|
||||||
.move(points.bottomLeft)
|
|
||||||
.line(points.bottomRight)
|
|
||||||
.line(points.topRight)
|
|
||||||
.line(points.topLeft)
|
|
||||||
.close()
|
|
||||||
.attr('class', 'fabric')
|
|
||||||
|
|
||||||
paths.all = paths.seam.clone().line(points.bottomLeft).close().attr('class', 'fabric')
|
|
||||||
|
|
||||||
paths.topHem = new Path()
|
|
||||||
.move(points.topLeftHem)
|
|
||||||
.line(points.topRightHem.shift(0, sa))
|
|
||||||
.attr('class', 'various dashed')
|
|
||||||
.attr('data-text', 'hem')
|
|
||||||
.attr('data-text-class', 'text-xs center')
|
|
||||||
|
|
||||||
macro('cutonfold', {
|
|
||||||
from: points.topCOF,
|
|
||||||
to: points.bottomCOF,
|
|
||||||
})
|
|
||||||
|
|
||||||
// Complete?
|
|
||||||
if (complete) {
|
|
||||||
points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
|
||||||
snippets.logo = new Snippet('logo', points.logo)
|
|
||||||
points.title = points.logo.shift(-90, 45)
|
|
||||||
macro('title', {
|
|
||||||
nr: 3,
|
|
||||||
at: points.title,
|
|
||||||
title: 'Pocket',
|
|
||||||
})
|
|
||||||
if (sa) {
|
|
||||||
paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Paperless?
|
|
||||||
if (paperless) {
|
|
||||||
macro('hd', {
|
|
||||||
from: points.bottomLeft,
|
|
||||||
to: points.bottomRight,
|
|
||||||
y: points.bottomLeft.y + sa + 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.bottomLeft,
|
|
||||||
to: points.topLeft,
|
|
||||||
x: points.topLeft.x - sa - 15,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return part
|
|
||||||
}
|
|
93
designs/albert/src/pocket.mjs
Normal file
93
designs/albert/src/pocket.mjs
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
import { bibLength, lengthBonus } from './front.mjs'
|
||||||
|
|
||||||
|
export const pocket = {
|
||||||
|
name: 'albert.pocket',
|
||||||
|
measurements: [ 'hpsToWaistBack', 'waistToKnee' ],
|
||||||
|
options: { bibLength, lengthBonus },
|
||||||
|
draft: function (part) {
|
||||||
|
const {
|
||||||
|
options,
|
||||||
|
measurements,
|
||||||
|
Point,
|
||||||
|
Path,
|
||||||
|
points,
|
||||||
|
paths,
|
||||||
|
Snippet,
|
||||||
|
snippets,
|
||||||
|
complete,
|
||||||
|
sa,
|
||||||
|
paperless,
|
||||||
|
macro,
|
||||||
|
} = part.shorthand()
|
||||||
|
|
||||||
|
let apronLength =
|
||||||
|
measurements.hpsToWaistBack * options.bibLength +
|
||||||
|
measurements.waistToKnee * (1 + options.lengthBonus)
|
||||||
|
let pocketSize = apronLength / 4
|
||||||
|
let hemWidth = 3 * sa
|
||||||
|
|
||||||
|
points.topLeft = new Point(0, 0)
|
||||||
|
points.topRight = new Point(pocketSize, 0)
|
||||||
|
points.topLeftHem = points.topLeft.shift(270, hemWidth)
|
||||||
|
points.topRightHem = points.topRight.shift(270, hemWidth)
|
||||||
|
points.bottomLeft = points.topLeftHem.shift(270, pocketSize)
|
||||||
|
points.bottomRight = points.topRightHem.shift(270, pocketSize)
|
||||||
|
|
||||||
|
points.topCOF = points.topLeft.shift(270, pocketSize / 5)
|
||||||
|
points.bottomCOF = points.bottomLeft.shift(90, pocketSize / 5)
|
||||||
|
|
||||||
|
paths.seam = new Path()
|
||||||
|
.move(points.bottomLeft)
|
||||||
|
.line(points.bottomRight)
|
||||||
|
.line(points.topRight)
|
||||||
|
.line(points.topLeft)
|
||||||
|
.close()
|
||||||
|
.attr('class', 'fabric')
|
||||||
|
|
||||||
|
paths.all = paths.seam.clone().line(points.bottomLeft).close().attr('class', 'fabric')
|
||||||
|
|
||||||
|
paths.topHem = new Path()
|
||||||
|
.move(points.topLeftHem)
|
||||||
|
.line(points.topRightHem.shift(0, sa))
|
||||||
|
.attr('class', 'various dashed')
|
||||||
|
.attr('data-text', 'hem')
|
||||||
|
.attr('data-text-class', 'text-xs center')
|
||||||
|
|
||||||
|
macro('cutonfold', {
|
||||||
|
from: points.topCOF,
|
||||||
|
to: points.bottomCOF,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Complete?
|
||||||
|
if (complete) {
|
||||||
|
points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
||||||
|
snippets.logo = new Snippet('logo', points.logo)
|
||||||
|
points.title = points.logo.shift(-90, 45)
|
||||||
|
macro('title', {
|
||||||
|
nr: 3,
|
||||||
|
at: points.title,
|
||||||
|
title: 'Pocket',
|
||||||
|
})
|
||||||
|
if (sa) {
|
||||||
|
paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paperless?
|
||||||
|
if (paperless) {
|
||||||
|
macro('hd', {
|
||||||
|
from: points.bottomLeft,
|
||||||
|
to: points.bottomRight,
|
||||||
|
y: points.bottomLeft.y + sa + 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.bottomLeft,
|
||||||
|
to: points.topLeft,
|
||||||
|
x: points.topLeft.x - sa - 15,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return part
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,131 +0,0 @@
|
||||||
export default function (part) {
|
|
||||||
let {
|
|
||||||
options,
|
|
||||||
measurements,
|
|
||||||
Point,
|
|
||||||
Path,
|
|
||||||
points,
|
|
||||||
paths,
|
|
||||||
Snippet,
|
|
||||||
snippets,
|
|
||||||
complete,
|
|
||||||
sa,
|
|
||||||
paperless,
|
|
||||||
macro,
|
|
||||||
} = part.shorthand()
|
|
||||||
|
|
||||||
let chestWidth = measurements.chest / 4
|
|
||||||
let bibWidth = chestWidth * options.bibWidth
|
|
||||||
/*
|
|
||||||
let apronWidth =
|
|
||||||
Math.max(measurements.hips, measurements.waist) *
|
|
||||||
(1 - options.backOpening)
|
|
||||||
*/
|
|
||||||
let apronWidth = measurements.waist * (1 - options.backOpening)
|
|
||||||
let backOpening = apronWidth - Math.max(measurements.hips, measurements.waist)
|
|
||||||
let hemWidth = 3 * sa
|
|
||||||
|
|
||||||
let hSpan = backOpening / 2 + bibWidth / 2
|
|
||||||
let vSpan =
|
|
||||||
measurements.hpsToWaistBack +
|
|
||||||
measurements.hpsToWaistBack -
|
|
||||||
measurements.hpsToWaistBack * options.bibLength
|
|
||||||
|
|
||||||
let strapWidth = (measurements.hpsToWaistBack * options.strapWidth) / 8
|
|
||||||
let strapLength =
|
|
||||||
Math.sqrt(hSpan * hSpan + vSpan * vSpan) + measurements.chest * options.chestDepth
|
|
||||||
/*
|
|
||||||
console.log('chestWidth ' + chestWidth)
|
|
||||||
console.log('backOpening ' + backOpening)
|
|
||||||
console.log('hSpan ' + hSpan)
|
|
||||||
console.log('vSpan ' + vSpan)
|
|
||||||
console.log('strapLength ' + strapLength)
|
|
||||||
*/
|
|
||||||
points.topLeft = new Point(0, 0)
|
|
||||||
points.topLeftHem = points.topLeft.shift(270, hemWidth)
|
|
||||||
points.topMiddle = new Point(strapWidth, 0)
|
|
||||||
points.topMiddleHem = new Point(strapWidth, hemWidth)
|
|
||||||
points.topRight = new Point(strapWidth * 2, 0)
|
|
||||||
points.bottomLeftHem = new Point(0, strapLength + hemWidth)
|
|
||||||
points.bottomLeft = new Point(0, strapLength + hemWidth * 2)
|
|
||||||
points.bottomMiddleHem = new Point(strapWidth, strapLength + hemWidth)
|
|
||||||
points.bottomMiddle = new Point(strapWidth, strapLength + hemWidth * 2)
|
|
||||||
points.bottomRight = new Point(strapWidth * 2, strapLength + hemWidth * 2)
|
|
||||||
|
|
||||||
paths.seam = new Path()
|
|
||||||
.move(points.topLeft)
|
|
||||||
.line(points.bottomLeft)
|
|
||||||
.line(points.bottomRight)
|
|
||||||
.line(points.topRight)
|
|
||||||
.line(points.topLeft)
|
|
||||||
.close()
|
|
||||||
.attr('class', 'fabric')
|
|
||||||
|
|
||||||
paths.topHem = new Path()
|
|
||||||
.move(points.topLeftHem)
|
|
||||||
.line(points.topMiddleHem)
|
|
||||||
.attr('class', 'various dashed')
|
|
||||||
.attr('data-text', 'attach')
|
|
||||||
.attr('data-text-class', 'text-xs center')
|
|
||||||
paths.bottomHem = new Path()
|
|
||||||
.move(points.bottomLeftHem)
|
|
||||||
.line(points.bottomMiddleHem)
|
|
||||||
.attr('class', 'various dashed')
|
|
||||||
.attr('data-text', 'attach')
|
|
||||||
.attr('data-text-class', 'text-xs center')
|
|
||||||
|
|
||||||
paths.fold = new Path()
|
|
||||||
.move(points.topMiddle)
|
|
||||||
.line(points.bottomMiddle)
|
|
||||||
.attr('class', 'various dashed')
|
|
||||||
.attr('data-text', 'fold')
|
|
||||||
.attr('data-text-class', 'text-xs center')
|
|
||||||
|
|
||||||
// Complete?
|
|
||||||
if (complete) {
|
|
||||||
points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
|
||||||
snippets.logo = new Snippet('logo', points.logo).attr('data-scale', 0.5)
|
|
||||||
points.title = points.logo.shift(-90, 50)
|
|
||||||
macro('title', {
|
|
||||||
nr: 2,
|
|
||||||
at: points.title,
|
|
||||||
title: 'Strap',
|
|
||||||
})
|
|
||||||
macro('crossBox', { from: points.topLeft, to: points.topMiddleHem })
|
|
||||||
macro('crossBox', { from: points.bottomLeftHem, to: points.bottomMiddle })
|
|
||||||
if (sa) {
|
|
||||||
paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Paperless?
|
|
||||||
if (paperless) {
|
|
||||||
macro('hd', {
|
|
||||||
from: points.bottomLeft,
|
|
||||||
to: points.bottomRight,
|
|
||||||
y: points.bottomLeft.y + sa + 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.bottomLeft,
|
|
||||||
to: points.topLeft,
|
|
||||||
x: points.topLeft.x - sa - 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.topMiddle,
|
|
||||||
to: points.topMiddleHem,
|
|
||||||
x: points.topMiddleHem.x + sa + 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.topMiddleHem,
|
|
||||||
to: points.bottomMiddleHem,
|
|
||||||
x: points.topMiddleHem.x + sa + 15,
|
|
||||||
})
|
|
||||||
macro('vd', {
|
|
||||||
from: points.bottomMiddleHem,
|
|
||||||
to: points.bottomMiddle,
|
|
||||||
x: points.bottomMiddleHem.x + sa + 15,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return part
|
|
||||||
}
|
|
144
designs/albert/src/strap.mjs
Normal file
144
designs/albert/src/strap.mjs
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
import { backOpening, bibWidth, bibLength, strapWidth } from './front.mjs'
|
||||||
|
|
||||||
|
export const strap = {
|
||||||
|
name: 'albert.strap',
|
||||||
|
measurements: [ 'chest', 'waist', 'hips', 'hpsToWaistBack' ],
|
||||||
|
options: {
|
||||||
|
backOpening,
|
||||||
|
bibWidth,
|
||||||
|
bibLength,
|
||||||
|
strapWidth,
|
||||||
|
chestDepth: { pct: 22, min: 15, max: 90, menu: 'fit' },
|
||||||
|
},
|
||||||
|
draft: function (part) {
|
||||||
|
const {
|
||||||
|
options,
|
||||||
|
measurements,
|
||||||
|
Point,
|
||||||
|
Path,
|
||||||
|
points,
|
||||||
|
paths,
|
||||||
|
Snippet,
|
||||||
|
snippets,
|
||||||
|
complete,
|
||||||
|
sa,
|
||||||
|
paperless,
|
||||||
|
macro,
|
||||||
|
} = part.shorthand()
|
||||||
|
|
||||||
|
let chestWidth = measurements.chest / 4
|
||||||
|
let bibWidth = chestWidth * options.bibWidth
|
||||||
|
/*
|
||||||
|
let apronWidth =
|
||||||
|
Math.max(measurements.hips, measurements.waist) *
|
||||||
|
(1 - options.backOpening)
|
||||||
|
*/
|
||||||
|
let apronWidth = measurements.waist * (1 - options.backOpening)
|
||||||
|
let backOpening = apronWidth - Math.max(measurements.hips, measurements.waist)
|
||||||
|
let hemWidth = 3 * sa
|
||||||
|
|
||||||
|
let hSpan = backOpening / 2 + bibWidth / 2
|
||||||
|
let vSpan =
|
||||||
|
measurements.hpsToWaistBack +
|
||||||
|
measurements.hpsToWaistBack -
|
||||||
|
measurements.hpsToWaistBack * options.bibLength
|
||||||
|
|
||||||
|
let strapWidth = (measurements.hpsToWaistBack * options.strapWidth) / 8
|
||||||
|
let strapLength =
|
||||||
|
Math.sqrt(hSpan * hSpan + vSpan * vSpan) + measurements.chest * options.chestDepth
|
||||||
|
/*
|
||||||
|
console.log('chestWidth ' + chestWidth)
|
||||||
|
console.log('backOpening ' + backOpening)
|
||||||
|
console.log('hSpan ' + hSpan)
|
||||||
|
console.log('vSpan ' + vSpan)
|
||||||
|
console.log('strapLength ' + strapLength)
|
||||||
|
*/
|
||||||
|
points.topLeft = new Point(0, 0)
|
||||||
|
points.topLeftHem = points.topLeft.shift(270, hemWidth)
|
||||||
|
points.topMiddle = new Point(strapWidth, 0)
|
||||||
|
points.topMiddleHem = new Point(strapWidth, hemWidth)
|
||||||
|
points.topRight = new Point(strapWidth * 2, 0)
|
||||||
|
points.bottomLeftHem = new Point(0, strapLength + hemWidth)
|
||||||
|
points.bottomLeft = new Point(0, strapLength + hemWidth * 2)
|
||||||
|
points.bottomMiddleHem = new Point(strapWidth, strapLength + hemWidth)
|
||||||
|
points.bottomMiddle = new Point(strapWidth, strapLength + hemWidth * 2)
|
||||||
|
points.bottomRight = new Point(strapWidth * 2, strapLength + hemWidth * 2)
|
||||||
|
|
||||||
|
paths.seam = new Path()
|
||||||
|
.move(points.topLeft)
|
||||||
|
.line(points.bottomLeft)
|
||||||
|
.line(points.bottomRight)
|
||||||
|
.line(points.topRight)
|
||||||
|
.line(points.topLeft)
|
||||||
|
.close()
|
||||||
|
.attr('class', 'fabric')
|
||||||
|
|
||||||
|
paths.topHem = new Path()
|
||||||
|
.move(points.topLeftHem)
|
||||||
|
.line(points.topMiddleHem)
|
||||||
|
.attr('class', 'various dashed')
|
||||||
|
.attr('data-text', 'attach')
|
||||||
|
.attr('data-text-class', 'text-xs center')
|
||||||
|
paths.bottomHem = new Path()
|
||||||
|
.move(points.bottomLeftHem)
|
||||||
|
.line(points.bottomMiddleHem)
|
||||||
|
.attr('class', 'various dashed')
|
||||||
|
.attr('data-text', 'attach')
|
||||||
|
.attr('data-text-class', 'text-xs center')
|
||||||
|
|
||||||
|
paths.fold = new Path()
|
||||||
|
.move(points.topMiddle)
|
||||||
|
.line(points.bottomMiddle)
|
||||||
|
.attr('class', 'various dashed')
|
||||||
|
.attr('data-text', 'fold')
|
||||||
|
.attr('data-text-class', 'text-xs center')
|
||||||
|
|
||||||
|
// Complete?
|
||||||
|
if (complete) {
|
||||||
|
points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
||||||
|
snippets.logo = new Snippet('logo', points.logo).attr('data-scale', 0.5)
|
||||||
|
points.title = points.logo.shift(-90, 50)
|
||||||
|
macro('title', {
|
||||||
|
nr: 2,
|
||||||
|
at: points.title,
|
||||||
|
title: 'Strap',
|
||||||
|
})
|
||||||
|
macro('crossBox', { from: points.topLeft, to: points.topMiddleHem })
|
||||||
|
macro('crossBox', { from: points.bottomLeftHem, to: points.bottomMiddle })
|
||||||
|
if (sa) {
|
||||||
|
paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paperless?
|
||||||
|
if (paperless) {
|
||||||
|
macro('hd', {
|
||||||
|
from: points.bottomLeft,
|
||||||
|
to: points.bottomRight,
|
||||||
|
y: points.bottomLeft.y + sa + 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.bottomLeft,
|
||||||
|
to: points.topLeft,
|
||||||
|
x: points.topLeft.x - sa - 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.topMiddle,
|
||||||
|
to: points.topMiddleHem,
|
||||||
|
x: points.topMiddleHem.x + sa + 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.topMiddleHem,
|
||||||
|
to: points.bottomMiddleHem,
|
||||||
|
x: points.topMiddleHem.x + sa + 15,
|
||||||
|
})
|
||||||
|
macro('vd', {
|
||||||
|
from: points.bottomMiddleHem,
|
||||||
|
to: points.bottomMiddle,
|
||||||
|
x: points.bottomMiddleHem.x + sa + 15,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return part
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,17 +1,16 @@
|
||||||
// This file is auto-generated.
|
// This file is auto-generated | Any changes you make will be overwritten.
|
||||||
// Changes you make will be overwritten.
|
import { Albert } from './dist/index.mjs'
|
||||||
import Pattern from './dist/index.mjs'
|
|
||||||
|
|
||||||
// Shared tests
|
// Shared tests
|
||||||
import { testPatternConfig } from '../../../tests/patterns/config.mjs'
|
import { testPatternConfig } from '../../../tests/designs/config.mjs'
|
||||||
import { testPatternDrafting } from '../../../tests/patterns/drafting.mjs'
|
import { testPatternDrafting } from '../../../tests/designs/drafting.mjs'
|
||||||
import { testPatternSampling } from '../../../tests/patterns/sampling.mjs'
|
import { testPatternSampling } from '../../../tests/designs/sampling.mjs'
|
||||||
|
|
||||||
// Test config
|
// Test config
|
||||||
testPatternConfig("albert", new Pattern())
|
testPatternConfig(Albert)
|
||||||
|
|
||||||
// Test drafting
|
// Test drafting - Change the second parameter to `true` to log errors
|
||||||
testPatternDrafting("albert", Pattern)
|
testPatternDrafting(Albert, false)
|
||||||
|
|
||||||
// Test sampling
|
// Test sampling - Change the second parameter to `true` to log errors
|
||||||
testPatternSampling( "albert", Pattern)
|
testPatternSampling(Albert, false)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue