1
0
Fork 0
freesewing/sites/dev/docs/guides/designs/stacks
Joost De Cock ab3204f9f1 chore: Port FreeSewing.dev to docusaurus
The replaces the NextJS site powering FreeSewing.dev with a Docusaurus
setup. It's part of my efforts to simplify FreeSewing's setup so we can
focus on our core value proposition.
2024-09-28 13:13:48 +02:00
..
readme.mdx chore: Port FreeSewing.dev to docusaurus 2024-09-28 13:13:48 +02:00

---
title: Stacks
sidebar_position: 110
---

[Stacks](/reference/api/stack) come into play when laying out a pattern.
The FreeSewing core library, by default, will handle the layout of a pattern
for you by placing all parts into stacks and arranging the stacks in as
small a space as possible.

That is _typically_ what you want, but not always. For example, when sampling
you want parts to be stacked on top of each other:

<Example settings="sample: { type: measurement, measurement: head }" withHead caption="A simple example of sampling the `head` measurement">
```js
({
  Point,
  points,
  Path,
  paths,
  Snippet,
  snippets,
  measurements,
  part
}) => {

  const size = measurements.head
  paths.box = new Path()
    .move(new Point(0,0))
    .line(new Point(0, size/3))
    .line(new Point(size, size/3))
    .line(new Point(size, 0))
    .addClass('fabric')
    .close()
  points.logo = new Point(size/2, size/5)
  snippets.logo = new Snippet('logo', points.logo)

  return part
}
```
</Example>

Under the hood, sampling uses multiple sets of settings and then uses stacks
to place them on top of each other.  But this functionality is also available
to patterns designers who want to use it.

Essentially, a stack is a collection of parts.
Parts in a stack act as layers and will be stacked directly on top
of each other.

You can stack parts from the same set, or from different sets.

:::note  FIXME
Include code example
:::

:::note

In the vast majority of cases, stacks will be handled for you by the
core library (like in the sampling example above).
By default, parts are added to a stack with the same name as the part,
so you only need to specify a stack if you want a different behavior.

:::

:::note RELATED

Please see [Assigning parts to stacks](/reference/api/part/config/stack)
for information about how to use stacks.

:::