2022-02-19 08:04:25 +01:00
|
|
|
---
|
2021-10-17 18:26:00 +02:00
|
|
|
title: layout
|
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-02-19 08:04:25 +01:00
|
|
|
The `layout` setting allows you to control the way pattern parts are
|
2022-12-14 21:02:30 -08:00
|
|
|
laid out on the pattern. Either automatic, explicit, or not at all.
|
2022-10-02 17:41:04 +02:00
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
|
|
|
```js
|
|
|
|
const settings = {
|
|
|
|
Boolean|Object layout=true
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
There are 3 scenarios:
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-02-20 14:44:38 +01:00
|
|
|
- layout is truthy: Do layout algorithmically
|
|
|
|
- layout is falsy: Do not do any layout apart from stacking all parts together
|
|
|
|
- layout is an object: Layout the parts as detailed in the layout object
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-02 17:41:04 +02:00
|
|
|
## example
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { Aaron } from "@freesewing/aaron"
|
|
|
|
|
|
|
|
const pattern = new aaron({
|
|
|
|
layout: false
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
## Notes
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-02 17:41:04 +02:00
|
|
|
### Behavior when layout is truthy
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-02-19 08:04:25 +01:00
|
|
|
This is the default behaviour. Parts will be laid without overlap in
|
|
|
|
a space that's a small as possible.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-02-19 08:04:25 +01:00
|
|
|
Don't expect miracles here.
|
|
|
|
It's one of those things humans are far better at than
|
2021-08-25 16:09:31 +02:00
|
|
|
computers.
|
|
|
|
|
2022-10-02 17:41:04 +02:00
|
|
|
### Behavior when layout is falsy
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
This will cause all parts to be laid out on top of each other.
|
|
|
|
|
|
|
|
It is almost certainly not what you want, but having all parts piled
|
|
|
|
on top of each other in the top left corner can be a good starting
|
|
|
|
point for a custom layout.
|
|
|
|
|
2022-10-02 17:41:04 +02:00
|
|
|
### Behavior when layout is a layout object
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
This allows you to control the layout by passing a layout object.
|
|
|
|
This object should be structures as such:
|
|
|
|
|
|
|
|
```js
|
2022-10-02 17:41:04 +02:00
|
|
|
import { Aaron } from "@freesewing/aaron"
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-02 17:41:04 +02:00
|
|
|
const pattern = new Aaron({
|
2021-08-25 16:09:31 +02:00
|
|
|
layout: {
|
2023-07-08 20:47:09 +02:00
|
|
|
width: 600,
|
|
|
|
height: 1000,
|
|
|
|
stacks: {
|
2021-08-25 16:09:31 +02:00
|
|
|
front: {
|
|
|
|
move: {
|
|
|
|
x: 14,
|
|
|
|
y: -202
|
|
|
|
}
|
|
|
|
},
|
|
|
|
back: {
|
|
|
|
rotate: 90,
|
|
|
|
flipX: true,
|
|
|
|
flipY, true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
For each part in the `parts` attribute of our layout object, there are 4 possible attributes:
|
|
|
|
|
2022-02-20 14:44:38 +01:00
|
|
|
- move: Expects an object with an `x` and `y` property, and will move the part by `x` along the X-axis and by `y` along the Y-axis
|
|
|
|
- rotate: Expects a number, and will rotate the part by number degrees around its center point
|
|
|
|
- flipX: Will flip/mirror the part horizontally
|
|
|
|
- flipY: Will flip/mirror the part vertically
|