1
0
Fork 0
freesewing/sites/dev/docs/reference/api/point/slope/readme.mdx

54 lines
822 B
Text
Raw Normal View History

2023-04-10 16:15:52 +00:00
---
title: Point.slope()
---
The `Point.slope()` method returns the slope (dy/dx) of a line between two Points.
2023-04-10 16:15:52 +00:00
## Signature
```js
2023-04-16 16:39:13 +00:00
point.slope(otherPoint)
2023-04-10 16:15:52 +00:00
```
## Example
<Example caption="An example of the Point.slope() method">
2023-04-16 16:39:13 +00:00
2023-04-10 16:15:52 +00:00
```js
2023-04-16 16:39:13 +00:00
2023-04-16 16:51:14 +00:00
({ Point, points, Path, paths, Snippet, snippets, part, macro }) => {
2023-04-10 16:15:52 +00:00
2023-04-16 16:39:13 +00:00
points.A = new Point(0,0)
2023-04-16 16:51:14 +00:00
points.B = new Point(200,150)
2023-04-16 16:39:13 +00:00
const slope = points.A.slope(points.B)
2023-04-16 16:51:14 +00:00
macro('hd', {
from: points.A,
to: points.B,
y: points.B.y,
id: 'macro1',
force: true,
2023-04-16 16:51:14 +00:00
})
macro('vd', {
to: points.B,
from: points.A,
x: 0,
id: 'macro2',
force: true,
2023-04-16 16:51:14 +00:00
})
2023-04-16 16:39:13 +00:00
paths.line = new Path()
.move(points.A)
.line(points.B)
.attr("class", "canvas")
2023-04-16 16:51:14 +00:00
.setText("Slope: " + slope, "center text-lg")
2023-04-10 16:15:52 +00:00
return part
}
2023-04-16 16:39:13 +00:00
2023-04-10 16:15:52 +00:00
```
</Example>