1
0
Fork 0

chore(octopussy): Ported to v3

This commit is contained in:
Joost De Cock 2022-09-05 13:37:46 +02:00
parent bc9332f2e0
commit e82cebe445
5 changed files with 79 additions and 80 deletions

View file

@ -1,49 +0,0 @@
import pkg from '../package.json' assert { type: 'json' }
const { version } = pkg
export default {
name: 'octoplushy',
version: version,
design: 'Wouter Van Wageningen',
code: 'Wouter Van Wageningen',
department: 'accessories',
type: 'pattern',
difficulty: 5,
optionGroups: {
style: ['size','type','armWidth','armLength','neckWidth','armTaper','bottomTopArmRatio','bottomArmReduction','bottomArmReductionPlushy'],
},
parts: ['headSection0', 'headSection1', 'armSection0', 'armSection1', 'eye0', 'eye1', 'eye2'],
measurements: [],
dependencies: {
eye0: 'headSection0',
eye1: 'headSection0',
eye2: 'headSection0',
armSection0: 'headSection0',
armSection1: 'headSection1',
},
inject: {},
hide: [],
options: {
sizeConstant: 200,
size: { pct: 100, min: 5, max: 500 },
type: { dflt: 'octoplushy', list: ['octoplushy', 'octopus', 'squid'] },
armWidth: { pct: 15, min: 10, max: 30 },
armLength: { pct: 200, min: 100, max: 500 },
neckWidth: { pct: 25, min: 25, max: 45 },
armTaper: { pct: 25, min: 0, max: 50 },
bottomTopArmRatio: { pct: 87, min: 75, max: 100 },
bottomArmReduction: {
pct: 90,
min: 75,
max: 125,
hide: ({ options }) => options.type == 'octoplushy',
},
bottomArmReductionPlushy: {
pct: 80,
min: 75,
max: 125,
hide: ({ options }) => options.type != 'octoplushy',
},
},
}

View file

@ -1,4 +1,6 @@
export default function (partNumber, part) {
import { headSection1, headSection2 } from './head.mjs'
function octoplushyArmSection(partNumber, part) {
const {
options,
Point,
@ -309,3 +311,14 @@ export default function (partNumber, part) {
return part
}
export const armSection1 = {
name: 'octoplushy.armSection1',
after: headSection1,
draft: (part) => octoplushyArmSection(0, part),
}
export const armSection2 = {
name: 'octoplushy.armSection2',
after: headSection2,
draft: (part) => octoplushyArmSection(1, part),
}

View file

@ -1,4 +1,6 @@
export default function (partNumber, part) {
import { headSection1 } from './head.mjs'
function octoplushyEye(partNumber, part) {
const {
options,
Point,
@ -127,3 +129,19 @@ export default function (partNumber, part) {
return part
}
export const eye1 = {
name: 'octoplushy.eye1',
after: headSection1,
draft: (part) => octoplushyEye(0, part),
}
export const eye2 = {
name: 'octoplushy.eye2',
after: headSection1,
draft: (part) => octoplushyEye(1, part),
}
export const eye3 = {
name: 'octoplushy.eye3',
after: headSection1,
draft: (part) => octoplushyEye(2, part),
}

View file

@ -1,8 +1,4 @@
// import mirror from '@freesewing/plugin-mirror'
// import { PostAddSharp } from '@material-ui/icons'
// import { Store } from "@material-ui/icons";
export default function (partNumber, part) {
function octoplushyHeadSection(partNumber, part) {
const {
options,
Point,
@ -607,3 +603,37 @@ export default function (partNumber, part) {
}
return part
}
const options = {
sizeConstant: 200,
size: { pct: 100, min: 5, max: 500, menu: 'style' },
type: { dflt: 'octoplushy', list: ['octoplushy', 'octopus', 'squid'], menu: 'style' },
armWidth: { pct: 15, min: 10, max: 30, menu: 'style' },
armLength: { pct: 200, min: 100, max: 500, menu: 'style' },
neckWidth: { pct: 25, min: 25, max: 45, menu: 'style' },
armTaper: { pct: 25, min: 0, max: 50, menu: 'style' },
bottomTopArmRatio: { pct: 87, min: 75, max: 100, menu: 'style' },
bottomArmReduction: {
pct: 90,
min: 75,
max: 125,
menu: ({ options }) => (options.type == 'octoplushy' ? 'style' : false),
},
bottomArmReductionPlushy: {
pct: 80,
min: 75,
max: 125,
menu: ({ options }) => (options.type != 'octoplushy' ? 'style' : false),
},
}
export const headSection1 = {
name: 'octoplushy.headSection1',
options,
draft: (part) => octoplushyHeadSection(0, part),
}
export const headSection2 = {
name: 'octoplushy.headSection2',
options,
draft: (part) => octoplushyHeadSection(1, part),
}

View file

@ -1,27 +1,14 @@
import freesewing from '@freesewing/core'
import plugins from '@freesewing/plugin-bundle'
import config from '../config'
import draftHeadSection from './headSection'
import draftArmSection from './armSection'
import draftEye from './eye'
import { Design } from '@freesewing/core'
import { data } from '../data.mjs'
import { headSection1, headSection2 } from './head.mjs'
import { armSection1, armSection2 } from './arm.mjs'
import { eye1, eye2, eye3 } from './eye.mjs'
// Create new design
const Octoplushy = new freesewing.Design(config, plugins)
// Attach the draft methods to the prototype
// Octoplushy.prototype.draftHeadSection = draftHeadSection
for (let i = 0; i < 2; i++) {
Octoplushy.prototype[`draftHeadSection${i}`] = (part) => draftHeadSection(i, part)
}
for (let i = 0; i < 2; i++) {
Octoplushy.prototype[`draftArmSection${i}`] = (part) => draftArmSection(i, part)
}
for (let i = 0; i < 3; i++) {
Octoplushy.prototype[`draftEye${i}`] = (part) => draftEye(i, part)
}
// Setup our new design
const Octoplushy = new Design({
data,
parts: [headSection1, headSection2, armSection1, armSection2, eye1, eye2, eye3],
})
// Named exports
export { config, Octoplushy }
// Default export
export default Octoplushy
export { headSection1, headSection2, armSection1, armSection2, eye1, eye2, eye3, Octoplushy }