1
0
Fork 0

[core] fix: stack anchoring (#261)

Fixes #54

Also adds the fabric class to lumina parts for proper line width and rainbow coloring.

The last commit is probably not right. It works, but I'm not sure if these are the right functions to change.

![image](/attachments/7a017a76-c7ba-4078-a1a1-e6c900f7d5ee)

Reviewed-on: https://codeberg.org/freesewing/freesewing/pulls/261
Reviewed-by: Joost De Cock <joostdecock@noreply.codeberg.org>
Co-authored-by: Jonathan Haas <haasjona@gmail.com>
Co-committed-by: Jonathan Haas <haasjona@gmail.com>
This commit is contained in:
Jonathan Haas 2025-04-18 13:00:40 +00:00 committed by Joost De Cock
parent 44e04a4cef
commit c9300e6739
8 changed files with 35 additions and 4 deletions

View file

@ -22,6 +22,7 @@ export const leg = {
.join(paths.frontWaistband) .join(paths.frontWaistband)
.join(paths.frontSplit) .join(paths.frontSplit)
.close() .close()
.addClass('fabric')
if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')

View file

@ -25,6 +25,7 @@ export const panel = {
.join(paths.panelHem.reverse()) .join(paths.panelHem.reverse())
.reverse() .reverse()
.close() .close()
.addClass('fabric')
if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')

View file

@ -80,6 +80,7 @@ export const pocket = {
.join(paths.frontPocket.reverse()) .join(paths.frontPocket.reverse())
.close() .close()
.reverse() .reverse()
.addClass('fabric')
if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')

View file

@ -109,6 +109,8 @@ export const waistband = {
.join(paths.waistband.reverse()) .join(paths.waistband.reverse())
} }
points.anchor = points.waistFront
paths.front = new Path() paths.front = new Path()
.move(points.waistbandFront) .move(points.waistbandFront)
.line(points.waistFront) .line(points.waistFront)
@ -152,7 +154,11 @@ export const waistband = {
.join(paths.waistband) .join(paths.waistband)
.hide() .hide()
paths.seam = new Path().move(points.waistbandFront).line(points.waistFront).join(paths.seamSA) paths.seam = new Path()
.move(points.waistbandFront)
.line(points.waistFront)
.join(paths.seamSA)
.addClass('fabric')
if (sa) { if (sa) {
const seamSA = paths.seamSA.offset(sa) const seamSA = paths.seamSA.offset(sa)

View file

@ -62,6 +62,7 @@ Part.prototype.asRenderProps = function () {
paths, paths,
points, points,
snippets, snippets,
anchor: points.anchor ?? new Point(0, 0),
attributes: this.attributes.asRenderProps(), attributes: this.attributes.asRenderProps(),
height: this.height, height: this.height,
width: this.width, width: this.width,

View file

@ -58,8 +58,19 @@ Stack.prototype.home = function () {
for (const part of this.getPartList()) { for (const part of this.getPartList()) {
part.__boundary() part.__boundary()
let partAnchor = part.points.anchor
let bounds = part
if (partAnchor) {
bounds = {
topLeft: part.topLeft.translate(-partAnchor.x, -partAnchor.y),
bottomRight: part.bottomRight.translate(-partAnchor.x, -partAnchor.y),
}
}
const { topLeft, bottomRight } = utils.getTransformedBounds( const { topLeft, bottomRight } = utils.getTransformedBounds(
part, bounds,
part.attributes.getAsArray('transform') part.attributes.getAsArray('transform')
) )

View file

@ -301,9 +301,15 @@ Svg.prototype.__renderPathText = function (path) {
* @return {string} svg - The SVG markup for the Part object * @return {string} svg - The SVG markup for the Part object
*/ */
Svg.prototype.__renderPart = function (part) { Svg.prototype.__renderPart = function (part) {
const attributes = part.attributes.clone()
attributes.add(
'transform',
`translate(${-part.asRenderProps().anchor.x}, ${-part.asRenderProps().anchor.y})`
)
let svg = this.__openGroup( let svg = this.__openGroup(
`${this.idPrefix}stack-${this.activeStack}-part-${part.name}`, `${this.idPrefix}stack-${this.activeStack}-part-${part.name}`,
part.attributes attributes
) )
for (let key in part.paths) { for (let key in part.paths) {
let path = part.paths[key] let path = part.paths[key]

View file

@ -54,7 +54,11 @@ export const Part = ({ stackName, partName, part, settings, components, strings,
const { Group } = components const { Group } = components
return ( return (
<Group {...getProps(part)} id={getId({ settings, stackName, partName })}> <Group
{...getProps(part)}
id={getId({ settings, stackName, partName })}
transform={`translate(${-part.anchor.x}, ${-part.anchor.y})`}
>
<PartInner {...{ stackName, partName, part, settings, components, strings, drillProps }} /> <PartInner {...{ stackName, partName, part, settings, components, strings, drillProps }} />
</Group> </Group>
) )