2021-10-17 18:26:00 +02:00
|
|
|
---
|
|
|
|
title: Pattern.render()
|
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-20 18:09:28 +02:00
|
|
|
The `Pattern.render()` method will render the pattern to SVG and return
|
|
|
|
that SVG as a string. It should only be called after calling
|
2021-09-25 17:05:18 +02:00
|
|
|
[Pattern.draft()](/reference/api/pattern/draft/) first.
|
|
|
|
|
2022-09-20 18:09:28 +02:00
|
|
|
## Pattern.render() signature
|
2021-09-25 17:05:18 +02:00
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
|
|
|
string pattern.render()
|
2022-02-19 08:04:25 +01:00
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-20 18:09:28 +02:00
|
|
|
## Pattern.render() example
|
2021-09-25 17:05:18 +02:00
|
|
|
|
|
|
|
```js
|
2022-09-20 18:09:28 +02:00
|
|
|
import { Aaron } from "@freesewing/aaron"
|
2021-09-25 17:05:18 +02:00
|
|
|
|
2023-10-30 19:27:24 +01:00
|
|
|
// Load some public test measurements from the FreeSewing backend
|
|
|
|
const measurements = (
|
|
|
|
await (
|
|
|
|
await fetch("https://backend3.freesewing.org/curated-sets/1.json")
|
|
|
|
).json()
|
|
|
|
).measurements
|
|
|
|
|
|
|
|
const pattern = new Aaron({ measurements })
|
2021-09-25 17:05:18 +02:00
|
|
|
|
|
|
|
const svg = pattern.draft().render()
|
2022-02-19 08:04:25 +01:00
|
|
|
```
|