2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-10-01 22:20:43 +02:00
|
|
|
title: utils.stretchToScale()
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-01 22:20:43 +02:00
|
|
|
The `utils.stretchToScale()` function calculates the scale for a given amount of
|
|
|
|
stretch.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
|
|
|
float utils.stretchToScale(float stretch)
|
|
|
|
```
|
|
|
|
|
2022-10-01 22:20:43 +02:00
|
|
|
## Notes
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
The way people measure stretch intuitively is different from the way we handle stretch in code.
|
|
|
|
|
2022-12-26 07:00:16 -08:00
|
|
|
When people say _25% stretch_ they mean that 10 cm fabric gets stretched to 12.5 cm fabric.
|
2021-08-25 16:09:31 +02:00
|
|
|
In code and on our patterns, that means we need to scale things by 80%.
|
|
|
|
|
2022-10-01 22:20:43 +02:00
|
|
|
This function does that by returning:
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
2022-10-01 23:13:39 +02:00
|
|
|
1 / (1 + parseFloat(stretch))
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|