1
0
Fork 0

chore(hortensia): Utilize expand for all reactangles and camelCase stuff

This commit is contained in:
joostdecock 2023-09-22 19:06:29 +02:00
parent 4c7326cb9a
commit 8d74e42d49
9 changed files with 152 additions and 68 deletions

View file

@ -4,23 +4,29 @@
"p": {
"top": "Top",
"bottom": "Bottom",
"bottompanel": "Bottom panel",
"frontpanel": "Front panel",
"sidepanel": "Side panel",
"sidepanelreinforcement": "Side panel reinforcement",
"bottomPanel": "Bottom panel",
"frontPanel": "Front panel",
"sidePanel": "Side panel",
"sidePanelReinforcement": "Side panel reinforcement",
"strap": "Strap",
"zipperpanel": "Zipper panel"
"zipperPanel": "Zipper panel"
},
"s": {
"SidePanel": "Side Panel",
"FrontBackPanel": "Front and Back Panel",
"BottomPanel": "Bottom Panel",
"ZipperPanel": "Zipper Panel",
"Strap": "Handle",
"cutBottomPanel.t": "The bottom panel is not shown",
"cutBottomPanel.d": "The **Bottom panel** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes seam allowance). You need to cut 1 from the main fabric, and 1 from the lining fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.",
"cutFrontPanel.t": "The front panel is not shown",
"cutFrontPanel.d": "The **Front panel** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes seam allowance). You need to cut 2 from the main fabric, and 2 from the lining fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.",
"cutStrap.t": "The strap is not shown",
"cutStrap.d": "The **Strap** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes seam allowance). You need to cut 2 from the main fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.",
"cutStrapReducedSa.t": "The strap is not shown (and has reduced seam allowance)",
"cutStrapReducedSa.d": "The **Strap** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes a reduced seam allowance of 80% of the strap width). You need to cut 2 from the main fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.",
"cutZipperPanel.t": "The zipper panel is not shown",
"cutZipperPanel.d": "The **Zipper panel** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes seam allowance). You need to cut 1 from the main fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.",
"strapLength": "Length of the handles",
"strapSaReduced.t": "The strap seam allowance is reduced",
"strapSaReduced.d": "Because of how narrow the strap is, we have reduced the seam allowance on it to be 80% of the strap width",
"handleWidth": "Width of the handles",
"zipperSize": "Standard zipper size",
"SidePanelReinforcement": "Side Reinforcement Panel"
"zipperSize": "Standard zipper size"
},
"o": {
"size": {

View file

@ -1,12 +1,50 @@
import { sidepanel } from './sidepanel.mjs'
import { sidePanel } from './sidepanel.mjs'
export const bottompanel = {
name: 'hortensia.bottompanel',
after: sidepanel,
draft: ({ store, options, Point, Path, points, paths, Snippet, snippets, sa, macro, part }) => {
export const bottomPanel = {
name: 'hortensia.bottomPanel',
after: sidePanel,
draft: ({
store,
expand,
units,
options,
Point,
Path,
points,
paths,
Snippet,
snippets,
sa,
macro,
part,
}) => {
const w = store.get('bottomPanelLength')
const h = store.get('depth')
if (expand) {
store.flag.preset('expandIsOn')
} else {
// Expand is off, do not draw the part but flag this to the user
store.flag.note({
msg: `hortensia:cutBottomPanel`,
replace: {
width: units(w + 2 * sa),
length: units(h + 2 * sa),
},
suggest: {
text: 'flag:show',
icon: 'expand',
update: {
settings: ['expand', 1],
},
},
})
// Also hint about expand
store.flag.preset('expandIsOff')
return part.hide()
}
points.topLeft = new Point(0, 0)
points.topRight = new Point(w, 0)
points.bottomLeft = new Point(0, h)
@ -33,7 +71,7 @@ export const bottompanel = {
macro('title', {
at: points.title,
nr: 3,
title: 'BottomPanel',
title: 'bottomPanel',
align: 'center',
})

View file

@ -1,4 +1,4 @@
export function bottomsidepanel(points, topMiddle, w, h, sizeRatio) {
export function bottomSidePanel(points, topMiddle, w, h, sizeRatio) {
const c = 0.551915024494 // circle constant
const cornerCP = 20 * sizeRatio

View file

@ -1,8 +1,8 @@
import { sidepanel } from './sidepanel.mjs'
import { sidePanel } from './sidepanel.mjs'
export const frontpanel = {
name: 'hortensia.frontpanel',
after: sidepanel,
export const frontPanel = {
name: 'hortensia.frontPanel',
after: sidePanel,
options: {
minHandleSpaceWidth: 80,
maxHandleSpaceWidth: 250,
@ -21,12 +21,38 @@ export const frontpanel = {
Snippet,
snippets,
sa,
expand,
units,
macro,
part,
}) => {
const w = store.get('frontPanelLength')
const h = store.get('depth')
if (expand) {
store.flag.preset('expandIsOn')
} else {
// Expand is off, do not draw the part but flag this to the user
store.flag.note({
msg: `hortensia:cutFrontPanel`,
replace: {
width: units(w + 2 * sa),
length: units(h + 2 * sa),
},
suggest: {
text: 'flag:show',
icon: 'expand',
update: {
settings: ['expand', 1],
},
},
})
// Also hint about expand
store.flag.preset('expandIsOff')
return part.hide()
}
points.topLeft = new Point(0, 0)
points.topRight = new Point(w, 0)
points.bottomLeft = new Point(0, h)
@ -86,8 +112,10 @@ export const frontpanel = {
id: 'att2',
})
store.cutlist.addCut({ cut: 2, from: 'fabric' })
store.cutlist.addCut({ cut: 2, material: 'lining' })
store.cutlist.setCut([
{ cut: 2, from: 'fabric' },
{ cut: 2, from: 'lining' },
])
points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
snippets.logo = new Snippet('logo', points.logo)
@ -98,7 +126,7 @@ export const frontpanel = {
macro('title', {
at: points.title,
nr: 2,
title: 'FrontPanel',
title: 'frontPanel',
align: 'center',
})

View file

@ -2,26 +2,26 @@ import { Design } from '@freesewing/core'
import { data } from '../data.mjs'
import { i18n } from '../i18n/index.mjs'
// Parts
import { sidepanel } from './sidepanel.mjs'
import { frontpanel } from './frontpanel.mjs'
import { bottompanel } from './bottompanel.mjs'
import { zipperpanel } from './zipperpanel.mjs'
import { sidepanelreinforcement } from './sidepanelreinforcement.mjs'
import { sidePanel } from './sidepanel.mjs'
import { frontPanel } from './frontpanel.mjs'
import { bottomPanel } from './bottompanel.mjs'
import { zipperPanel } from './zipperpanel.mjs'
import { sidePanelReinforcement } from './sidepanelreinforcement.mjs'
import { strap } from './strap.mjs'
// Create new design
const Hortensia = new Design({
data,
parts: [sidepanel, frontpanel, bottompanel, zipperpanel, sidepanelreinforcement, strap],
parts: [sidePanel, frontPanel, bottomPanel, zipperPanel, sidePanelReinforcement, strap],
})
// Named exports
export {
sidepanel,
frontpanel,
bottompanel,
zipperpanel,
sidepanelreinforcement,
sidePanel,
frontPanel,
bottomPanel,
zipperPanel,
sidePanelReinforcement,
strap,
Hortensia,
i18n,

View file

@ -1,11 +1,11 @@
import { bottomsidepanel } from './bottomsidepanel.mjs'
import { bottomSidePanel } from './bottomsidepanel.mjs'
// Default width and height:
const width = 230
const height = 330
export const sidepanel = {
name: 'hortensia.sidepanel',
export const sidePanel = {
name: 'hortensia.sidePanel',
options: {
width,
height,
@ -80,7 +80,7 @@ export const sidepanel = {
points.topMiddleCPL = points.topMiddle.shift(180, topCP)
points.topMiddleCPR = points.topMiddle.shift(0, topCP * 1.1)
bottomsidepanel(points, points.topMiddle, w, h, sizeRatio)
bottomSidePanel(points, points.topMiddle, w, h, sizeRatio)
points.shoulderLeft = points.bottomLeft.shift(90, sideLength)
points.shoulderLeftCP = points.shoulderLeft.shift(90, shoulderCP)
@ -155,7 +155,7 @@ export const sidepanel = {
macro('title', {
at: points.title,
nr: 1,
title: 'sidepanel',
title: 'sidePanel',
align: 'center',
})

View file

@ -1,9 +1,9 @@
import { sidepanel } from './sidepanel.mjs'
import { bottomsidepanel } from './bottomsidepanel.mjs'
import { sidePanel } from './sidepanel.mjs'
import { bottomSidePanel } from './bottomsidepanel.mjs'
export const sidepanelreinforcement = {
name: 'hortensia.sidepanelreinforcement',
after: sidepanel,
export const sidePanelReinforcement = {
name: 'hortensia.sidePanelReinforcement',
after: sidePanel,
draft: ({ store, Point, Path, points, paths, sa, macro, part }) => {
const w = store.get('width')
const h = store.get('sidePanelReinforcementHeight')
@ -13,7 +13,7 @@ export const sidepanelreinforcement = {
points.topLeft = points.topMiddle.shift(180, w / 2)
points.topRight = points.topMiddle.shift(0, w / 2)
bottomsidepanel(points, points.topMiddle, w, h, sizeRatio)
bottomSidePanel(points, points.topMiddle, w, h, sizeRatio)
paths.seam = new Path()
.move(points.topMiddle)
@ -35,7 +35,7 @@ export const sidepanelreinforcement = {
macro('title', {
at: points.title,
nr: 4,
title: 'sidepanelreinforcement',
title: 'sidePanelReinforcement',
scale: 0.25,
align: 'center',
})

View file

@ -1,8 +1,8 @@
import { sidepanel } from './sidepanel.mjs'
import { sidePanel } from './sidepanel.mjs'
export const strap = {
name: 'hortensia.strap',
after: sidepanel,
after: sidePanel,
options: {
strapLength: { pct: 160, min: 75, max: 250, menu: 'style' },
handleWidth: { pct: 8.6, min: 4, max: 25, menu: 'style' },
@ -11,13 +11,28 @@ export const strap = {
const w = store.get('width') * options.handleWidth
const h = store.get('depth') * options.strapLength
if (!expand) {
let reducedSa = false
if (sa > w * 0.8) {
sa = w * 0.8
reducedSa = true
store.flag.warn({
msg: `hortensia:strapSaReduced`,
replace: {
width: units(w + 2 * sa),
length: units(h + 2 * sa),
},
})
}
if (expand) store.flag.preset('expandIsOn')
else {
// Expand is on, do not draw the part but flag this to the user
store.flag.note({
msg: `hortensia:strap`,
msg: reducedSa ? `hortensia:cutStrapReducedSa` : `hortensia:cutStrap`,
replace: {
width: units(w),
length: units(h),
width: units(w + 2 * sa),
length: units(h + 2 * sa),
},
suggest: {
text: 'flag:show',
@ -28,15 +43,11 @@ export const strap = {
},
})
// Also hint about expand
store.flag.preset('expand')
store.flag.preset('expandIsOff')
return part.hide()
}
if (sa > w * 0.8) {
sa = w * 0.8
}
points.topLeft = new Point(-w, 0)
points.topMiddle = new Point(0, 0)
points.topRight = new Point(w, 0)

View file

@ -1,17 +1,18 @@
import { sidepanel } from './sidepanel.mjs'
import { sidePanel } from './sidepanel.mjs'
export const zipperpanel = {
name: 'hortensia.zipperpanel',
after: sidepanel,
export const zipperPanel = {
name: 'hortensia.zipperPanel',
after: sidePanel,
draft: ({ store, Point, Path, points, paths, sa, macro, expand, units, part }) => {
const z = store.get('zipperWidth')
const w = (store.get('zipperPanelWidth') - z) / 2
const h = store.get('depth')
if (!expand) {
// Expand is on, do not draw the part but flag this to the user
if (expand) store.flag.preset('expandIsOn')
else {
// Expand is off, do not draw the part but flag this to the user
store.flag.note({
msg: `hortensia:zipperpanel`,
msg: `hortensia:cutZipperPanel`,
replace: {
width: units(w),
length: units(h),
@ -25,7 +26,7 @@ export const zipperpanel = {
},
})
// Also hint about expand
store.flag.preset('expand')
store.flag.preset('expandIsOff')
return part.hide()
}