1
0
Fork 0
freesewing/sites/dev/docs/reference/api/utils/stretchtoscale
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: utils.stretchToScale()
---

The `utils.stretchToScale()` function calculates the scale for a given amount of
stretch.

## Signature

```js
float utils.stretchToScale(float stretch)
```

## Notes

The way people measure stretch intuitively is different from the way we handle stretch in code.

When people say fabric has _25% stretch_ they mean that 10 cm of fabric can
stretch to 12.5 cm.
In code that means we would need to scale non-stretch lengths by 80%
to get the correct lengths to use in patterns with 25% stretch fabric.

Pattern designers need a way to calculate the scaling factor to use for
their pattern part lengths, given a fabric stretch percentage.
This function does that by returning:

```js
1 / (1 + parseFloat(stretch))
```