48 lines
1.1 KiB
Markdown
48 lines
1.1 KiB
Markdown
![]() |
---
|
||
|
title: utils.curveEdge()
|
||
|
---
|
||
|
|
||
|
The `utils.curveEdge()` function finds the edge of a cubic Bezier curve, given the curve, the edge to find ("top", "bottom", "left", or "right"), and the number of steps to divide the curve into while walking it.
|
||
|
|
||
|
## Signature
|
||
|
|
||
|
```js
|
||
|
Point utils.curveEdge(
|
||
|
Bezier curve,
|
||
|
string edge,
|
||
|
int steps = 500)
|
||
|
```
|
||
|
|
||
|
## Example
|
||
|
|
||
|
<Example caption="A Utils.curveEdge() example">
|
||
|
```js
|
||
|
({ Point, points, Path, paths, Snippet, snippets, utils, part }) => {
|
||
|
|
||
|
points.A = new Point(20, 10)
|
||
|
points.Acp = new Point(310, 40)
|
||
|
points.Bcp = new Point(-210, 40)
|
||
|
points.B = new Point(100, 70)
|
||
|
|
||
|
paths.pathA = new Path()
|
||
|
.move(points.A)
|
||
|
.curve(points.Acp, points.Bcp, points.B)
|
||
|
|
||
|
/*
|
||
|
let curveA = new Bezier(
|
||
|
{ x: points.A.x, y: points.A.y },
|
||
|
{ x: points.Acp.x, y: points.Acp.y },
|
||
|
{ x: points.Bcp.x, y: points.Bcp.y },
|
||
|
{ x: points.B.x, y: points.B.y }
|
||
|
)
|
||
|
*/
|
||
|
let curveA = utils.bezier(points.A, points.Acp, points.Bcp, points.B)
|
||
|
|
||
|
points.edge = utils.curveEdge(curveA, "left")
|
||
|
snippets.edge = new Snippet("notch", points.edge)
|
||
|
|
||
|
return part
|
||
|
}
|
||
|
```
|
||
|
</Example>
|