Stacks
Stacks 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:
- Preview
- Code
- X-Ray
({
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
}
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.
Include code example
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.
Please see Assigning parts to stacks for information about how to use stacks.