2021-11-06 18:36:35 +01:00
|
|
|
---
|
|
|
|
title: Point.dist()
|
|
|
|
---
|
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
The `Point.dist()` method returns the distance (in mm) between this point and
|
|
|
|
the point you pass it.
|
2021-11-06 18:36:35 +01:00
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
## Signature
|
2021-11-06 19:03:54 +01:00
|
|
|
|
2021-11-06 18:36:35 +01:00
|
|
|
```js
|
|
|
|
float point.dist(Point point)
|
|
|
|
```
|
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
## Example
|
2021-11-06 18:36:35 +01:00
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
<Example caption="An example of the Point.dist() method">
|
2021-11-06 18:36:35 +01:00
|
|
|
```js
|
2022-09-27 19:15:57 +02:00
|
|
|
({ Point, points, Path, paths, units, part }) => {
|
|
|
|
|
|
|
|
points.from = new Point(10, 10)
|
|
|
|
points.to = new Point(80, 70)
|
2022-12-30 07:47:29 -08:00
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
points.text = points.from
|
|
|
|
.shiftFractionTowards(points.to, 0.6)
|
|
|
|
.setText(units(points.from.dist(points.to)), 'text-sm fill-note center')
|
2022-12-30 07:47:29 -08:00
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
paths.line = new Path()
|
|
|
|
.move(points.from)
|
|
|
|
.line(points.to)
|
2022-09-29 16:50:42 +02:00
|
|
|
.setClass('dashed')
|
2022-12-30 07:47:29 -08:00
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
return part
|
|
|
|
}
|
2021-11-06 18:36:35 +01:00
|
|
|
```
|
2022-09-27 19:15:57 +02:00
|
|
|
</Example>
|