2021-11-06 18:36:35 +01:00
|
|
|
---
|
|
|
|
title: Point.dist()
|
|
|
|
---
|
|
|
|
|
|
|
|
A point's `dist()` method returns the distance (in mm) between this point and the point you pass it.
|
|
|
|
|
2021-11-06 19:03:54 +01:00
|
|
|
## Point.dist() signature
|
|
|
|
|
2021-11-06 18:36:35 +01:00
|
|
|
```js
|
|
|
|
float point.dist(Point point)
|
|
|
|
```
|
|
|
|
|
2021-11-06 19:03:54 +01:00
|
|
|
## Point.dist() example
|
|
|
|
|
2022-01-19 11:31:39 +01:00
|
|
|
<Example part="point_dist">
|
|
|
|
An example of the Point.dist() method
|
|
|
|
</Example>
|
2021-11-06 18:36:35 +01:00
|
|
|
|
|
|
|
```js
|
|
|
|
let { Point, points, Path, paths } = part.shorthand()
|
|
|
|
|
|
|
|
points.from = new Point(10, 10)
|
|
|
|
points.to = new Point(80, 70)
|
|
|
|
|
|
|
|
points.text = points.from
|
|
|
|
.shiftFractionTowards(points.to, 0.6)
|
|
|
|
.attr('data-text', points.from.dist(points.to) + 'mm')
|
|
|
|
.attr('data-text-class', 'text-sm fill-note center')
|
|
|
|
|
|
|
|
paths.line = new Path()
|
|
|
|
.move(points.from)
|
|
|
|
.line(points.to)
|
|
|
|
.attr('class', 'dashed')
|
|
|
|
|
|
|
|
return part
|
|
|
|
```
|