2021-10-17 18:26:00 +02:00
---
title: flip
---
2021-08-25 16:09:31 +02:00
2022-09-30 01:45:37 +02:00
The `flip` macro flips (mirrors) an entire part vertically around either the
2023-10-29 17:20:35 +01:00
X-axis or the Y-axis.
It is provided by the [flip plugin](/reference/plugins/flip).
2024-09-28 13:13:48 +02:00
:::note
2023-10-29 17:20:35 +01:00
##### Not a core-plugins macro
The `flip` macro is not provided by the [core-plugins](/reference/plugins/core),
so you need to load the [flip plugin](/reference/plugins/flip) explicitly
if you want to use it.
2024-09-28 13:13:48 +02:00
:::
2021-08-25 16:09:31 +02:00
2022-09-30 01:45:37 +02:00
## Signature
```js
macro('flip', { String axis=x })
```
## Example
<Example caption="Example of the flip macro">
2021-08-25 16:09:31 +02:00
```js
2022-09-30 01:45:37 +02:00
({ Point, points, Path, paths, Snippet, snippets, macro, part }) => {
points.a = new Point(0,0)
points.b = new Point(90,20)
paths.a = new Path().move(points.a).line(points.b).setClass('dotted note')
snippets.a = new Snippet(
'logo',
paths.a.shiftFractionAlong(0.5)
).attr('data-scale', 0.2)
macro('flip')
return part
}
2021-08-25 16:09:31 +02:00
```
2022-09-30 01:45:37 +02:00
</Example>
## Configuration
2021-08-25 16:09:31 +02:00
2022-02-19 08:04:25 +01:00
| Property | Default | Type | Description |
2022-01-18 09:01:58 +01:00
|----------------:|---------|---------------------|-------------|
| `axis` | 'x' | The axis to flip around. Either `x` or `y` |
2022-09-30 01:45:37 +02:00
## Notes
2021-08-25 16:09:31 +02:00
2022-01-18 09:01:58 +01:00
Under the hood, this macro will:
2021-10-17 18:26:00 +02:00
2022-02-20 14:44:38 +01:00
- Go through all Points in your Part, and multiply their (X or Y)-coordinate by -1
2022-12-14 12:52:37 -08:00
- Go through all the Paths in your Part, and for each drawing operation will multiply the (X or Y)-coordinate by -1
2022-02-20 14:44:38 +01:00
- Go through all the Snippets in your Part and multiply the (X or Y)-coordinate of the anchor point by -1
2022-12-09 20:59:53 -08:00
- Add a 'flipped` Attribute to Points and Paths to keep track of the number of times they have been flipped (to avoid issues when multiple flips are performed)