Design guide

Hi there and welcome to this guide that explains how FreeSewing designs work.

it’s about what goes on under the hood each time a sewing pattern is generated by FreeSewing.

This illustration is a good starting point to gain a better understanding of the structure of a FreeSewing design:

Settings draft() Stack 0 Stack 1 Stack 2 Set 0 Set 1 Part A (set 0) Part B (set 0) Part C (set 0) Part A (set 1) Part B (set 1) Part C (set 1) Design render() getRenderProps() Render stage Settings Set 0 Settings Set 1 points paths snippets points paths snippets points paths snippets setStore 0 points paths snippets points paths snippets points paths snippets setStore 1 Pattern Store SVG ReactSvelteVueJS...

If it looks like a lot don’t despair. I included all the info on the graphical overview, but most of it you can safely ignore and consider under the hood unless you want to do some really advanced things with FreeSewing.

If we look at our image through squinted eyes, we can identify three areas:

NOTE

The left and right parts are all about how to integrate FreeSewing in your frontend. In other words, how you’ll plug it into your website, or online store, or a mobile application.

We’ll briefly cover those areas in this page. But a deep-dive into those topics is outside the scope of this guide.

The settings

On the left, we have the settings box. It represents the settings that are provided by the user.

Most of the settings are the same for all designs generated with FreeSewing as they are provided by the core library.

Noteworthy exceptions are the measurements and options keys as they are defined by the pattern design.

In other words, different patterns will required different measurements and provide different options. But all patterns will allow users to set the units (for example).

TIP

Settings are provided by passing them to the Pattern constructor

NOTE
Multiset support

Since version 3 of FreeSewing, you can pass multiple sets of settings to Pattern.draft(). We call this multset support.

In 99% of the cases, you will only have a single set of settings, and you can mostly forget about this feature. It is typically used to compare different drafts or to draft for different sets of measurements (for example).

Rendering your pattern

By rendering the pattern, we mean to generate the output to show to the user.

This can be done in two different ways:

Render to SVG

The core library ships with a renderer that will render your pattern to SVG.

To use it, call Pattern.render() which will return an SVG string.

BYOR (bring your own renderer)

If you’d like more fine-grained control over the output, you can use your own renderer.

To do so, call Pattern.getRenderProps() which will return all the data you need to render your pattern in the way you prefer.

NOTE|

This is what we use on these documentation pages to render with React

The pattern

Last but not least, we’ve arrived at the central item: the pattern itself. The pattern is a container that holds all your parts, along with a (pattern-wide) store.

In reality, your pattern is a constructor that takes the user’s settings as input and will return an instantiated pattern.

That pattern instance will have a draft() method which will do the actual work of drafting the pattern. Once drafted, the pattern can be rendered.

While the pattern does a lot of heavy lifting behind the scenes, we can content ourselves by understanding its different building blocks: