1
0
Fork 0

feat: Export Bezier in shorthand call + docs

This commit is contained in:
Joost De Cock 2022-12-12 18:45:51 +01:00
parent e3aa8b1d7e
commit c5d4eae079
3 changed files with 5 additions and 5 deletions

View file

@ -41,6 +41,7 @@ access the following properties:
| `unhide` | See [the unhide documentation](/reference/api/part/unhide) | | `unhide` | See [the unhide documentation](/reference/api/part/unhide) |
| `units` | A version of [`utils.units()`](/reference/api/utils/units) that is preconfigured with the user's chosenunits | | `units` | A version of [`utils.units()`](/reference/api/utils/units) that is preconfigured with the user's chosenunits |
| `utils` | See [the utils documentation](/reference/api/utils) | | `utils` | See [the utils documentation](/reference/api/utils) |
| `Bezier` | The [bezier-js](https://pomax.github.io/bezierjs/) library's `Bezier` named export |
|| **_Return value_** | || **_Return value_** |
| `part` | Your draft method **must** return this | | `part` | Your draft method **must** return this |

View file

@ -17,7 +17,7 @@ Point utils.curveEdge(
<Example caption="A Utils.curveEdge() example"> <Example caption="A Utils.curveEdge() example">
```js ```js
({ Point, points, Path, paths, Snippet, snippets, utils, part }) => { ({ Point, points, Path, paths, Snippet, snippets, utils, Bezier, part }) => {
points.A = new Point(20, 10) points.A = new Point(20, 10)
points.Acp = new Point(310, 40) points.Acp = new Point(310, 40)
@ -28,15 +28,12 @@ Point utils.curveEdge(
.move(points.A) .move(points.A)
.curve(points.Acp, points.Bcp, points.B) .curve(points.Acp, points.Bcp, points.B)
/* const curveA = new Bezier(
let curveA = new Bezier(
{ x: points.A.x, y: points.A.y }, { x: points.A.x, y: points.A.y },
{ x: points.Acp.x, y: points.Acp.y }, { x: points.Acp.x, y: points.Acp.y },
{ x: points.Bcp.x, y: points.Bcp.y }, { x: points.Bcp.x, y: points.Bcp.y },
{ x: points.B.x, y: points.B.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") points.edge = utils.curveEdge(curveA, "left")
snippets.edge = new Snippet("notch", points.edge) snippets.edge = new Snippet("notch", points.edge)

View file

@ -1,3 +1,4 @@
import { Bezier } from 'bezier-js'
import { Attributes } from './attributes.mjs' import { Attributes } from './attributes.mjs'
import * as utils from './utils.mjs' import * as utils from './utils.mjs'
import { Point, pointsProxy } from './point.mjs' import { Point, pointsProxy } from './point.mjs'
@ -122,6 +123,7 @@ Part.prototype.shorthand = function () {
store: this.context.store, store: this.context.store,
units: this.__unitsClosure(), units: this.__unitsClosure(),
utils: utils, utils: utils,
Bezier: Bezier,
} }
// Add top-level store methods and add a part name parameter // Add top-level store methods and add a part name parameter
const partName = this.name const partName = this.name