1
0
Fork 0

feat(plugin-sprinkle): Support scale and rotate in macro

This commit is contained in:
Joost De Cock 2022-01-18 14:57:14 +01:00
parent 1addd578fd
commit f15063095c
2 changed files with 11 additions and 4 deletions

View file

@ -5,7 +5,9 @@ title: sprinkle
The `sprinkle` macro facilitates adding snippets to your pattern in bulk. The `sprinkle` macro facilitates adding snippets to your pattern in bulk.
It is by the [sprinkle plugin](/reference/plugins/sprinkle). It is by the [sprinkle plugin](/reference/plugins/sprinkle).
<Example part="plugin_sprinkle" caption="Example of button snippets sprinkled on a pattern by this macro" /> <Example part="plugin_sprinkle">
Example of button snippets sprinkled on a pattern by this macro
</Example>
```js ```js
macro('sprinkle', { macro('sprinkle', {
@ -18,5 +20,7 @@ macro('sprinkle', {
|------------:|---------|------------------|-------------| |------------:|---------|------------------|-------------|
| `snippet` | | String | Name of the snippet to sprinkle | | `snippet` | | String | Name of the snippet to sprinkle |
| `on` | `[]` | Array of strings | An array with **the names** of points to add the snippet on | | `on` | `[]` | Array of strings | An array with **the names** of points to add the snippet on |
| `scale` | 1 | number | Scale for the individual snippets |
| `rotate` | 0 | number | Rotation for the individual snippets |

View file

@ -8,8 +8,11 @@ export default {
}, },
macros: { macros: {
sprinkle: function (so) { sprinkle: function (so) {
for (let pid of so.on) for (let pid of so.on) {
this.snippets[pid + '-' + so.snippet] = new this.Snippet(so.snippet, this.points[pid]) this.snippets[pid + '-' + so.snippet] = new this.Snippet(so.snippet, this.points[pid])
}, if (so.scale) this.snippets[pid + '-' + so.snippet].attr('data-scale', so.scale)
}, if (so.rotate) this.snippets[pid + '-' + so.snippet].attr('data-rotate', so.rotate)
}
}
}
} }