1
0
Fork 0

chore(markdown): Updated Point.flipX() docs

This commit is contained in:
Joost De Cock 2022-09-29 15:41:12 +02:00
parent 70c19a6219
commit 20ab68ca7b

View file

@ -2,64 +2,67 @@
title: Point.flipX()
---
A point's `flipX()` method returns a new `Point` that mirrors the original point around the X-value of the point you pass it.
If you do not pass in a point, it will default to mirroring around an X-value of zero.
The `Point.flipX()` method returns a new `Point` that mirrors the original
point around the X-value of the point you pass it. If you do not pass in a
point, it will default to mirroring around an X-value of zero.
## Point.flipX() signature
## Signature
```js
Point point.flipX(Point mirror = false)
```
## Point.flipX() example
## Example
<Example part="point_flipx">
An example of the Point.flipX() method
<Example caption="An example of the Point.flipX() method">
```js
({ Point, points, Path, paths, part }) => {
points.top = new Point(50, 10)
points.out1 = new Point(70, 30)
points.in1 = new Point(55, 35)
points.out2 = new Point(75, 50)
points.in2 = new Point(60, 55)
points.out3 = new Point(80, 70)
points.in3 = new Point(55, 70)
points.trunkOut = new Point(55, 80)
points.trunkIn = new Point(50, 80)
points._out1 = points.out1.flipX(points.top)
points._in1 = points.in1.flipX(points.top)
points._out2 = points.out2.flipX(points.top)
points._in2 = points.in2.flipX(points.top)
points._out3 = points.out3.flipX(points.top)
points._in3 = points.in3.flipX(points.top)
points._trunkOut = points.trunkOut.flipX(points.top)
points.bottom = new Point(50, 80)
paths.tree = new Path()
.move(points.top)
.line(points.out1)
.line(points.in1)
.line(points.out2)
.line(points.in2)
.line(points.out3)
.line(points.in3)
.line(points.trunkOut)
.line(points._trunkOut)
.line(points._in3)
.line(points._out3)
.line(points._in2)
.line(points._out2)
.line(points._in1)
.line(points._out1)
.close();
paths.mirror = new Path()
.move(points.top)
.line(points.bottom)
.setClass("note dashed")
return part
}
```
</Example>
```js
let { Point, points, Path, paths } = part.shorthand();
points.top = new Point(50, 10);
points.out1 = new Point(70, 30);
points.in1 = new Point(55, 35);
points.out2 = new Point(75, 50);
points.in2 = new Point(60, 55);
points.out3 = new Point(80, 70);
points.in3 = new Point(55, 70);
points.trunkOut = new Point(55, 80);
points.trunkIn = new Point(50, 80);
points._out1 = points.out1.flipX(points.top);
points._in1 = points.in1.flipX(points.top);
points._out2 = points.out2.flipX(points.top);
points._in2 = points.in2.flipX(points.top);
points._out3 = points.out3.flipX(points.top);
points._in3 = points.in3.flipX(points.top);
points._trunkOut = points.trunkOut.flipX(points.top);
points.bottom = new Point(50, 80);
paths.tree = new Path()
.move(points.top)
.line(points.out1)
.line(points.in1)
.line(points.out2)
.line(points.in2)
.line(points.out3)
.line(points.in3)
.line(points.trunkOut)
.line(points._trunkOut)
.line(points._in3)
.line(points._out3)
.line(points._in2)
.line(points._out2)
.line(points._in1)
.line(points._out1)
.close();
paths.mirror = new Path()
.move(points.top)
.line(points.bottom)
.attr("class", "note dashed");
```