2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-09-27 18:24:35 +02:00
|
|
|
title: Path.close()
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
The `Path.close()` method closes a path by drawing a straight line from the current position to the path's start.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
|
|
|
Path path.close()
|
|
|
|
```
|
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::tipThis method is chainable as it returns the `Path` object:::
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
## Example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
<Example caption="Example of the Path.close() method">
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
2022-09-27 18:24:35 +02:00
|
|
|
({ Point, points, Path, paths, part }) => {
|
|
|
|
|
|
|
|
points.from = new Point(10, 20)
|
|
|
|
points.cp2 = new Point(60, 30)
|
|
|
|
points.to = new Point(90, 20)
|
2022-12-30 07:47:29 -08:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
paths.line = new Path()
|
|
|
|
.move(points.from)
|
|
|
|
._curve(points.cp2, points.to)
|
|
|
|
.close()
|
|
|
|
.reverse() // To keep text from being upside-down
|
|
|
|
.setText('Path._close()', 'text-sm right fill-note')
|
|
|
|
|
|
|
|
return part
|
|
|
|
}
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
2022-09-27 18:24:35 +02:00
|
|
|
</Example>
|