plotboilerplate 1.23.2 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/index.esm.js +8351 -6928
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/plotboilerplate.browser.min.js +1 -1
- package/dist/plotboilerplate.browser.min.js.map +1 -1
- package/dist/plotboilerplate.js +1590 -123
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +4 -2
- package/src/cjs/BezierPath.d.ts +41 -5
- package/src/cjs/BezierPath.js +52 -2
- package/src/cjs/BezierPath.js.map +1 -1
- package/src/cjs/Bounds.d.ts +67 -3
- package/src/cjs/Bounds.js +101 -3
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/Circle.d.ts +46 -4
- package/src/cjs/Circle.js +82 -3
- package/src/cjs/Circle.js.map +1 -1
- package/src/cjs/CircleSector.d.ts +51 -2
- package/src/cjs/CircleSector.js +112 -3
- package/src/cjs/CircleSector.js.map +1 -1
- package/src/cjs/CubicBezierCurve.d.ts +113 -7
- package/src/cjs/CubicBezierCurve.js +281 -33
- package/src/cjs/CubicBezierCurve.js.map +1 -1
- package/src/cjs/Line.d.ts +38 -3
- package/src/cjs/Line.js +64 -1
- package/src/cjs/Line.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +4 -2
- package/src/cjs/PlotBoilerplate.js +9 -12
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Polygon.d.ts +153 -6
- package/src/cjs/Polygon.js +304 -23
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/Triangle.d.ts +73 -4
- package/src/cjs/Triangle.js +94 -2
- package/src/cjs/Triangle.js.map +1 -1
- package/src/cjs/VEllipse.d.ts +62 -3
- package/src/cjs/VEllipse.js +181 -17
- package/src/cjs/VEllipse.js.map +1 -1
- package/src/cjs/VEllipseSector.d.ts +86 -2
- package/src/cjs/VEllipseSector.js +148 -4
- package/src/cjs/VEllipseSector.js.map +1 -1
- package/src/cjs/Vector.d.ts +12 -2
- package/src/cjs/Vector.js +15 -2
- package/src/cjs/Vector.js.map +1 -1
- package/src/cjs/VertTuple.d.ts +39 -10
- package/src/cjs/VertTuple.js +49 -11
- package/src/cjs/VertTuple.js.map +1 -1
- package/src/cjs/Vertex.d.ts +18 -2
- package/src/cjs/Vertex.js +22 -2
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/draw.d.ts +1 -0
- package/src/cjs/draw.js +2 -1
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawutilssvg.js +24 -0
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/geomutils.d.ts +32 -1
- package/src/cjs/geomutils.js +47 -1
- package/src/cjs/geomutils.js.map +1 -1
- package/src/cjs/interfaces/core.d.ts +39 -0
- package/src/cjs/interfaces/core.js +2 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/algorithms/PolygonInset.d.ts +184 -0
- package/src/cjs/utils/algorithms/PolygonInset.js +431 -0
- package/src/cjs/utils/algorithms/PolygonInset.js.map +1 -0
- package/src/cjs/utils/algorithms/clearDuplicateVertices.d.ts +5 -4
- package/src/cjs/utils/algorithms/clearDuplicateVertices.js +6 -3
- package/src/cjs/utils/algorithms/clearDuplicateVertices.js.map +1 -1
- package/src/cjs/utils/algorithms/convexPolygonIncircle.d.ts +2 -1
- package/src/cjs/utils/algorithms/convexPolygonIncircle.js +14 -6
- package/src/cjs/utils/algorithms/convexPolygonIncircle.js.map +1 -1
- package/src/cjs/utils/algorithms/findPolygonSelfIntersections.d.ts +2 -1
- package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js +3 -3
- package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
- package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.d.ts +3 -2
- package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js +11 -9
- package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
- package/src/cjs/utils/createRandomizedPolygon.d.ts +14 -0
- package/src/cjs/utils/createRandomizedPolygon.js +32 -0
- package/src/cjs/utils/createRandomizedPolygon.js.map +1 -0
- package/src/cjs/utils/detectDarkMode.js.map +1 -1
- package/src/cjs/utils/dom/guiSizeToggler.d.ts +2 -1
- package/src/cjs/utils/dom/guiSizeToggler.js +5 -3
- package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -1
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +9 -7
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +37 -23
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +10 -1
- package/src/cjs/utils/helpers/CircleSectorHelper.js +19 -20
- package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/cjs/utils/helpers/VEllipseHelper.d.ts +30 -0
- package/src/cjs/utils/helpers/VEllipseHelper.js +86 -0
- package/src/cjs/utils/helpers/VEllipseHelper.js.map +1 -0
- package/src/cjs/utils/helpers/VEllipseSectorHelper.d.ts +42 -3
- package/src/cjs/utils/helpers/VEllipseSectorHelper.js +107 -25
- package/src/cjs/utils/helpers/VEllipseSectorHelper.js.map +1 -1
- package/src/createDemoDrawables.js +3 -1
- package/src/esm/BezierPath.d.ts +41 -5
- package/src/esm/BezierPath.js +50 -2
- package/src/esm/BezierPath.js.map +1 -1
- package/src/esm/Bounds.d.ts +67 -3
- package/src/esm/Bounds.js +101 -3
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/Circle.d.ts +46 -4
- package/src/esm/Circle.js +79 -3
- package/src/esm/Circle.js.map +1 -1
- package/src/esm/CircleSector.d.ts +51 -2
- package/src/esm/CircleSector.js +108 -3
- package/src/esm/CircleSector.js.map +1 -1
- package/src/esm/CubicBezierCurve.d.ts +113 -7
- package/src/esm/CubicBezierCurve.js +277 -33
- package/src/esm/CubicBezierCurve.js.map +1 -1
- package/src/esm/Line.d.ts +38 -3
- package/src/esm/Line.js +62 -1
- package/src/esm/Line.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +4 -2
- package/src/esm/PlotBoilerplate.js +9 -12
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Polygon.d.ts +153 -6
- package/src/esm/Polygon.js +301 -23
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/Triangle.d.ts +73 -4
- package/src/esm/Triangle.js +91 -2
- package/src/esm/Triangle.js.map +1 -1
- package/src/esm/VEllipse.d.ts +62 -3
- package/src/esm/VEllipse.js +178 -17
- package/src/esm/VEllipse.js.map +1 -1
- package/src/esm/VEllipseSector.d.ts +86 -2
- package/src/esm/VEllipseSector.js +146 -7
- package/src/esm/VEllipseSector.js.map +1 -1
- package/src/esm/Vector.d.ts +12 -2
- package/src/esm/Vector.js +15 -2
- package/src/esm/Vector.js.map +1 -1
- package/src/esm/VertTuple.d.ts +39 -10
- package/src/esm/VertTuple.js +49 -11
- package/src/esm/VertTuple.js.map +1 -1
- package/src/esm/Vertex.d.ts +18 -2
- package/src/esm/Vertex.js +22 -2
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/draw.d.ts +1 -0
- package/src/esm/draw.js +2 -1
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawutilssvg.js +24 -0
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/geomutils.d.ts +32 -1
- package/src/esm/geomutils.js +47 -1
- package/src/esm/geomutils.js.map +1 -1
- package/src/esm/interfaces/core.d.ts +39 -0
- package/src/esm/interfaces/core.js +2 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/algorithms/PolygonInset.d.ts +184 -0
- package/src/esm/utils/algorithms/PolygonInset.js +424 -0
- package/src/esm/utils/algorithms/PolygonInset.js.map +1 -0
- package/src/esm/utils/algorithms/clearDuplicateVertices.d.ts +5 -4
- package/src/esm/utils/algorithms/clearDuplicateVertices.js +6 -3
- package/src/esm/utils/algorithms/clearDuplicateVertices.js.map +1 -1
- package/src/esm/utils/algorithms/convexPolygonIncircle.d.ts +2 -1
- package/src/esm/utils/algorithms/convexPolygonIncircle.js +15 -7
- package/src/esm/utils/algorithms/convexPolygonIncircle.js.map +1 -1
- package/src/esm/utils/algorithms/createRandomizedPolygon.d.ts +14 -0
- package/src/esm/utils/algorithms/createRandomizedPolygon.js +28 -0
- package/src/esm/utils/algorithms/createRandomizedPolygon.js.map +1 -0
- package/src/esm/utils/algorithms/findPolygonSelfIntersections.d.ts +2 -1
- package/src/esm/utils/algorithms/findPolygonSelfIntersections.js +3 -3
- package/src/esm/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
- package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.d.ts +3 -2
- package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js +11 -9
- package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
- package/src/esm/utils/createRandomizedPolygon.d.ts +14 -0
- package/src/esm/utils/createRandomizedPolygon.js +28 -0
- package/src/esm/utils/createRandomizedPolygon.js.map +1 -0
- package/src/esm/utils/detectDarkMode.js.map +1 -1
- package/src/esm/utils/dom/guiSizeToggler.d.ts +2 -1
- package/src/esm/utils/dom/guiSizeToggler.js +4 -2
- package/src/esm/utils/dom/guiSizeToggler.js.map +1 -1
- package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +9 -7
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js +35 -22
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/esm/utils/helpers/CircleSectorHelper.d.ts +10 -1
- package/src/esm/utils/helpers/CircleSectorHelper.js +19 -20
- package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/esm/utils/helpers/VEllipseHelper.d.ts +30 -0
- package/src/esm/utils/helpers/VEllipseHelper.js +81 -0
- package/src/esm/utils/helpers/VEllipseHelper.js.map +1 -0
- package/src/esm/utils/helpers/VEllipseSectorHelper.d.ts +42 -3
- package/src/esm/utils/helpers/VEllipseSectorHelper.js +106 -24
- package/src/esm/utils/helpers/VEllipseSectorHelper.js.map +1 -1
- package/src/ts/BezierPath.ts +58 -5
- package/src/ts/Bounds.ts +110 -6
- package/src/ts/Circle.ts +87 -5
- package/src/ts/CircleSector.ts +115 -5
- package/src/ts/CubicBezierCurve.ts +332 -42
- package/src/ts/Line.ts +66 -3
- package/src/ts/PlotBoilerplate.ts +10 -12
- package/src/ts/Polygon.ts +329 -27
- package/src/ts/Triangle.ts +101 -5
- package/src/ts/VEllipse.ts +214 -19
- package/src/ts/VEllipseSector.ts +154 -8
- package/src/ts/Vector.ts +16 -2
- package/src/ts/VertTuple.ts +53 -13
- package/src/ts/Vertex.ts +24 -3
- package/src/ts/draw.ts +2 -1
- package/src/ts/drawutilssvg.ts +29 -0
- package/src/ts/geomutils.ts +49 -1
- package/src/ts/interfaces/core.ts +42 -0
- package/src/ts/utils/algorithms/PolygonInset.ts +529 -0
- package/src/ts/utils/algorithms/clearDuplicateVertices.ts +11 -8
- package/src/ts/utils/algorithms/convexPolygonIncircle.ts +82 -78
- package/src/ts/utils/algorithms/findPolygonSelfIntersections.ts +25 -26
- package/src/ts/utils/algorithms/splitPolygonToNonIntersecting.ts +92 -99
- package/src/ts/utils/createRandomizedPolygon.ts +31 -0
- package/src/ts/utils/detectDarkMode.ts +1 -3
- package/src/ts/utils/dom/guiSizeToggler.ts +4 -2
- package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +45 -29
- package/src/ts/utils/helpers/CircleSectorHelper.ts +115 -125
- package/src/ts/utils/helpers/VEllipseHelper.ts +113 -0
- package/src/ts/utils/helpers/VEllipseSectorHelper.ts +142 -25
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A helper for VEllipses.
|
|
3
|
+
*
|
|
4
|
+
* @author Ikaros Kappler
|
|
5
|
+
* @date 2025-03-31
|
|
6
|
+
* @modified 2025-04-02 Adding `VEllipseHelper.drawHandleLines()`.
|
|
7
|
+
* @modified 2025-04-09 Adding `VEllipseHelper.destroy()`.
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
import { VEllipse } from "../../VEllipse";
|
|
11
|
+
import { Vertex } from "../../Vertex";
|
|
12
|
+
import { DrawLib } from "../../interfaces";
|
|
13
|
+
export declare class VEllipseHelper {
|
|
14
|
+
private readonly ellipse;
|
|
15
|
+
private readonly rotationControlPoint;
|
|
16
|
+
private _rotationControlLine;
|
|
17
|
+
private _centerPointHandler;
|
|
18
|
+
private _rotationPointHandler;
|
|
19
|
+
constructor(ellipse: VEllipse, rotationControlPoint: Vertex);
|
|
20
|
+
private _handleDragCenterPoint;
|
|
21
|
+
private _handleRotationCenterPoint;
|
|
22
|
+
/**
|
|
23
|
+
* Draw grey handle lines.
|
|
24
|
+
*
|
|
25
|
+
* @param {DrawLib<any>} draw - The draw library instance to use.
|
|
26
|
+
* @param {DrawLib<any>} fill - The fill library instance to use.
|
|
27
|
+
*/
|
|
28
|
+
drawHandleLines(draw: DrawLib<any>, fill: DrawLib<any>): void;
|
|
29
|
+
detroy(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A helper for VEllipses.
|
|
4
|
+
*
|
|
5
|
+
* @author Ikaros Kappler
|
|
6
|
+
* @date 2025-03-31
|
|
7
|
+
* @modified 2025-04-02 Adding `VEllipseHelper.drawHandleLines()`.
|
|
8
|
+
* @modified 2025-04-09 Adding `VEllipseHelper.destroy()`.
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VEllipseHelper = void 0;
|
|
13
|
+
var Line_1 = require("../../Line");
|
|
14
|
+
var VEllipseHelper = /** @class */ (function () {
|
|
15
|
+
function VEllipseHelper(ellipse, rotationControlPoint) {
|
|
16
|
+
this.ellipse = ellipse;
|
|
17
|
+
this.rotationControlPoint = rotationControlPoint;
|
|
18
|
+
// const rotationControlLine: Line = new Line(ellipse.center, rotationControlPoint);
|
|
19
|
+
this._rotationControlLine = new Line_1.Line(ellipse.center, rotationControlPoint);
|
|
20
|
+
// +---------------------------------------------------------------------
|
|
21
|
+
// | Listen for the center to be moved.
|
|
22
|
+
// +-------------------------------------------
|
|
23
|
+
// ellipse.center.listeners.addDragListener((event: VertEvent) => {
|
|
24
|
+
// rotationControlPoint.add(event.params.dragAmount);
|
|
25
|
+
// });
|
|
26
|
+
ellipse.center.listeners.addDragListener((this._centerPointHandler = this._handleDragCenterPoint()));
|
|
27
|
+
// +---------------------------------------------------------------------
|
|
28
|
+
// | Listen for rotation changes.
|
|
29
|
+
// +-------------------------------------------
|
|
30
|
+
// rotationControlPoint.listeners.addDragListener((_event: VertEvent) => {
|
|
31
|
+
// var newRotation = rotationControlLine.angle();
|
|
32
|
+
// var rDiff = newRotation - ellipse.rotation;
|
|
33
|
+
// ellipse.rotation = newRotation;
|
|
34
|
+
// ellipse.axis.rotate(rDiff, ellipse.center);
|
|
35
|
+
// });
|
|
36
|
+
rotationControlPoint.listeners.addDragListener((this._rotationPointHandler = this._handleRotationCenterPoint()));
|
|
37
|
+
}
|
|
38
|
+
VEllipseHelper.prototype._handleDragCenterPoint = function () {
|
|
39
|
+
var _self = this;
|
|
40
|
+
return function (event) {
|
|
41
|
+
_self.rotationControlPoint.add(event.params.dragAmount);
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
VEllipseHelper.prototype._handleRotationCenterPoint = function () {
|
|
45
|
+
var _self = this;
|
|
46
|
+
return function (_event) {
|
|
47
|
+
var newRotation = _self._rotationControlLine.angle();
|
|
48
|
+
var rDiff = newRotation - _self.ellipse.rotation;
|
|
49
|
+
_self.ellipse.rotation = newRotation;
|
|
50
|
+
_self.ellipse.axis.rotate(rDiff, _self.ellipse.center);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Draw grey handle lines.
|
|
55
|
+
*
|
|
56
|
+
* @param {DrawLib<any>} draw - The draw library instance to use.
|
|
57
|
+
* @param {DrawLib<any>} fill - The fill library instance to use.
|
|
58
|
+
*/
|
|
59
|
+
VEllipseHelper.prototype.drawHandleLines = function (draw, fill) {
|
|
60
|
+
// Draw rotation handle line
|
|
61
|
+
draw.line(this.ellipse.center, this.rotationControlPoint, "rgba(192,64,128,0.333)", 1.0, {
|
|
62
|
+
dashOffset: 0.0,
|
|
63
|
+
dashArray: [4, 2]
|
|
64
|
+
});
|
|
65
|
+
// Draw helper box
|
|
66
|
+
draw.setCurrentId("".concat(this.ellipse.uid, "_e0"));
|
|
67
|
+
draw.setCurrentClassName("".concat(this.ellipse.className, "-v-line"));
|
|
68
|
+
draw.line(this.ellipse.center.clone().add(0, this.ellipse.signedRadiusV()).rotate(this.ellipse.rotation, this.ellipse.center), this.ellipse.axis, "rgba(64,128,192,0.333)", 1.0, {
|
|
69
|
+
dashOffset: 0.0,
|
|
70
|
+
dashArray: [4, 2]
|
|
71
|
+
});
|
|
72
|
+
draw.setCurrentId("".concat(this.ellipse.uid, "_e1"));
|
|
73
|
+
draw.setCurrentClassName("".concat(this.ellipse.className, "-h-line"));
|
|
74
|
+
draw.line(this.ellipse.center.clone().add(this.ellipse.signedRadiusH(), 0).rotate(this.ellipse.rotation, this.ellipse.center), this.ellipse.axis, "rgba(64,128,192,0.333)", 1.0, {
|
|
75
|
+
dashOffset: 0.0,
|
|
76
|
+
dashArray: [4, 2]
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
VEllipseHelper.prototype.detroy = function () {
|
|
80
|
+
this.ellipse.center.listeners.removeDragListener(this._centerPointHandler);
|
|
81
|
+
this.rotationControlPoint.listeners.removeDragListener(this._rotationPointHandler);
|
|
82
|
+
};
|
|
83
|
+
return VEllipseHelper;
|
|
84
|
+
}());
|
|
85
|
+
exports.VEllipseHelper = VEllipseHelper;
|
|
86
|
+
//# sourceMappingURL=VEllipseHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VEllipseHelper.js","sourceRoot":"","sources":["../../../ts/utils/helpers/VEllipseHelper.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,mCAAkC;AAMlC;IASE,wBAAY,OAAiB,EAAE,oBAA4B;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QAEjD,oFAAoF;QACpF,IAAI,CAAC,oBAAoB,GAAG,IAAI,WAAI,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;QAE3E,yEAAyE;QACzE,uCAAuC;QACvC,+CAA+C;QAC/C,mEAAmE;QACnE,uDAAuD;QACvD,MAAM;QACN,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;QAErG,yEAAyE;QACzE,iCAAiC;QACjC,+CAA+C;QAC/C,0EAA0E;QAC1E,mDAAmD;QACnD,gDAAgD;QAChD,oCAAoC;QACpC,gDAAgD;QAChD,MAAM;QACN,oBAAoB,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAC;IACnH,CAAC;IAEO,+CAAsB,GAA9B;QACE,IAAM,KAAK,GAAG,IAAI,CAAC;QACnB,OAAO,UAAC,KAAgB;YACtB,KAAK,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC1D,CAAC,CAAC;IACJ,CAAC;IAEO,mDAA0B,GAAlC;QACE,IAAM,KAAK,GAAG,IAAI,CAAC;QACnB,OAAO,UAAC,MAAiB;YACvB,IAAI,W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AC,OAAO,CAAC,GAAG,QAAK,CAAC,CAAC;QAC5C,IAAI,CAAC,mBAAmB,CAAC,UAAG,IAAI,CAAC,OAAO,CAAC,SAAS,YAAS,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,CACP,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EACnH,IAAI,CAAC,OAAO,CAAC,IAAI,EACjB,wBAAwB,EACxB,GAAG,EACH;YACE,UAAU,EAAE,GAAG;YACf,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SAClB,CACF,CAAC;IACJ,CAAC;IAED,+BAAM,GAAN;QACE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC3E,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACrF,CAAC;IACH,qBAAC;AAAD,CAAC,AAhGD,IAgGC;AAhGY,wCAAc"}
|
|
@@ -1,12 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A helper for VEllipseSectors.
|
|
3
3
|
*
|
|
4
|
-
* @author
|
|
5
|
-
* @date
|
|
6
|
-
* @
|
|
4
|
+
* @author Ikaros Kappler
|
|
5
|
+
* @date 2021-03-24
|
|
6
|
+
* @modified 2025-04-02 Adding `VEllipseSectorHelper.drawHandleLines`.
|
|
7
|
+
* @modified 2025-04-07 Modifying the calculation of `startAngle` and `endAngle` from the rotation control point: wrapping result into [0,TWO_PI).
|
|
8
|
+
* @modified 2025-04-09 Adding the `VEllipseSectorHelper.destroy` method.
|
|
9
|
+
* @version 1.1.0
|
|
7
10
|
*/
|
|
8
11
|
import { VEllipseSector } from "../../VEllipseSector";
|
|
9
12
|
import { Vertex } from "../../Vertex";
|
|
13
|
+
import { DrawLib } from "../../interfaces";
|
|
10
14
|
export declare class VEllipseSectorHelper {
|
|
15
|
+
private sector;
|
|
16
|
+
private startAngleControlPoint;
|
|
17
|
+
private endAngleControlPoint;
|
|
18
|
+
private rotationControlPoint;
|
|
19
|
+
private _rotationControlLine;
|
|
20
|
+
private _startAngleControlLine;
|
|
21
|
+
private _endAngleControlLine;
|
|
22
|
+
private _centerHandler;
|
|
23
|
+
private _rotationHandler;
|
|
24
|
+
private _startAngleHandler;
|
|
25
|
+
private _endAngleHandler;
|
|
11
26
|
constructor(sector: VEllipseSector, startAngleControlPoint: Vertex, endAngleControlPoint: Vertex, rotationControlPoint: Vertex);
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new drag handler for the circle sector's start control point.
|
|
29
|
+
*
|
|
30
|
+
* @private
|
|
31
|
+
* @method _handleDragStartControlPoint
|
|
32
|
+
* @instance
|
|
33
|
+
* @memberof CircleSectorHelper
|
|
34
|
+
* @returns A new event handler.
|
|
35
|
+
*/
|
|
36
|
+
private _handleDragCenterPoint;
|
|
37
|
+
private _handleDragRotationControlPoint;
|
|
38
|
+
private _handleDragStartAngleControlPoint;
|
|
39
|
+
private _handleDragEndAngleControlPoint;
|
|
40
|
+
/**
|
|
41
|
+
* Draw grey handle lines.
|
|
42
|
+
*
|
|
43
|
+
* @param {DrawLib<any>} draw - The draw library instance to use.
|
|
44
|
+
* @param {DrawLib<any>} fill - The fill library instance to use.
|
|
45
|
+
*/
|
|
46
|
+
drawHandleLines(draw: DrawLib<any>, fill: DrawLib<any>): void;
|
|
47
|
+
/**
|
|
48
|
+
* Destroy this VEllipseHandler which means: all listeners are being removed.
|
|
49
|
+
*/
|
|
50
|
+
destroy(): void;
|
|
12
51
|
}
|
|
@@ -2,50 +2,132 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* A helper for VEllipseSectors.
|
|
4
4
|
*
|
|
5
|
-
* @author
|
|
6
|
-
* @date
|
|
7
|
-
* @
|
|
5
|
+
* @author Ikaros Kappler
|
|
6
|
+
* @date 2021-03-24
|
|
7
|
+
* @modified 2025-04-02 Adding `VEllipseSectorHelper.drawHandleLines`.
|
|
8
|
+
* @modified 2025-04-07 Modifying the calculation of `startAngle` and `endAngle` from the rotation control point: wrapping result into [0,TWO_PI).
|
|
9
|
+
* @modified 2025-04-09 Adding the `VEllipseSectorHelper.destroy` method.
|
|
10
|
+
* @version 1.1.0
|
|
8
11
|
*/
|
|
9
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
13
|
exports.VEllipseSectorHelper = void 0;
|
|
11
14
|
var Line_1 = require("../../Line");
|
|
15
|
+
var geomutils_1 = require("../../geomutils");
|
|
12
16
|
var VEllipseSectorHelper = /** @class */ (function () {
|
|
13
17
|
function VEllipseSectorHelper(sector, startAngleControlPoint, endAngleControlPoint, rotationControlPoint) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
this.sector = sector;
|
|
19
|
+
this.startAngleControlPoint = startAngleControlPoint;
|
|
20
|
+
this.endAngleControlPoint = endAngleControlPoint;
|
|
21
|
+
this.rotationControlPoint = rotationControlPoint;
|
|
22
|
+
// const rotationControlLine: Line = new Line(sector.ellipse.center, rotationControlPoint);
|
|
23
|
+
this._rotationControlLine = new Line_1.Line(sector.ellipse.center, rotationControlPoint);
|
|
24
|
+
// const startAngleControlLine: Line = new Line(sector.ellipse.center, startAngleControlPoint);
|
|
25
|
+
this._startAngleControlLine = new Line_1.Line(sector.ellipse.center, startAngleControlPoint);
|
|
26
|
+
// const endAngleControlLine: Line = new Line(sector.ellipse.center, endAngleControlPoint);
|
|
27
|
+
this._endAngleControlLine = new Line_1.Line(sector.ellipse.center, endAngleControlPoint);
|
|
17
28
|
// +---------------------------------------------------------------------
|
|
18
29
|
// | Listen for the center to be moved.
|
|
19
30
|
// +-------------------------------------------
|
|
20
|
-
sector.ellipse.center.listeners.addDragListener(
|
|
21
|
-
startAngleControlPoint.add(event.params.dragAmount);
|
|
22
|
-
endAngleControlPoint.add(event.params.dragAmount);
|
|
23
|
-
rotationControlPoint.add(event.params.dragAmount);
|
|
24
|
-
});
|
|
31
|
+
sector.ellipse.center.listeners.addDragListener((this._centerHandler = this._handleDragCenterPoint()));
|
|
25
32
|
// +---------------------------------------------------------------------
|
|
26
33
|
// | Listen for rotation changes.
|
|
27
34
|
// +-------------------------------------------
|
|
28
|
-
rotationControlPoint.listeners.addDragListener(
|
|
29
|
-
var newRotation = rotationControlLine.angle();
|
|
30
|
-
var rDiff = newRotation - sector.ellipse.rotation;
|
|
31
|
-
sector.ellipse.rotation = newRotation;
|
|
32
|
-
sector.ellipse.axis.rotate(rDiff, sector.ellipse.center);
|
|
33
|
-
startAngleControlPoint.rotate(rDiff, sector.ellipse.center);
|
|
34
|
-
endAngleControlPoint.rotate(rDiff, sector.ellipse.center);
|
|
35
|
-
});
|
|
35
|
+
rotationControlPoint.listeners.addDragListener((this._rotationHandler = this._handleDragRotationControlPoint()));
|
|
36
36
|
// +---------------------------------------------------------------------
|
|
37
37
|
// | Listen for start angle changes.
|
|
38
38
|
// +-------------------------------------------
|
|
39
|
-
startAngleControlPoint.listeners.addDragListener(
|
|
40
|
-
sector.startAngle = startAngleControlLine.angle() - sector.ellipse.rotation;
|
|
41
|
-
});
|
|
39
|
+
startAngleControlPoint.listeners.addDragListener((this._startAngleHandler = this._handleDragStartAngleControlPoint()));
|
|
42
40
|
// +---------------------------------------------------------------------
|
|
43
41
|
// | Listen for end angle changes.
|
|
44
42
|
// +-------------------------------------------
|
|
45
|
-
endAngleControlPoint.listeners.addDragListener(
|
|
46
|
-
sector.endAngle = endAngleControlLine.angle() - sector.ellipse.rotation;
|
|
47
|
-
});
|
|
43
|
+
endAngleControlPoint.listeners.addDragListener((this._endAngleHandler = this._handleDragEndAngleControlPoint()));
|
|
48
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new drag handler for the circle sector's start control point.
|
|
47
|
+
*
|
|
48
|
+
* @private
|
|
49
|
+
* @method _handleDragStartControlPoint
|
|
50
|
+
* @instance
|
|
51
|
+
* @memberof CircleSectorHelper
|
|
52
|
+
* @returns A new event handler.
|
|
53
|
+
*/
|
|
54
|
+
VEllipseSectorHelper.prototype._handleDragCenterPoint = function () {
|
|
55
|
+
var _self = this;
|
|
56
|
+
return function (event) {
|
|
57
|
+
_self.startAngleControlPoint.add(event.params.dragAmount);
|
|
58
|
+
_self.endAngleControlPoint.add(event.params.dragAmount);
|
|
59
|
+
_self.rotationControlPoint.add(event.params.dragAmount);
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
VEllipseSectorHelper.prototype._handleDragRotationControlPoint = function () {
|
|
63
|
+
var _self = this;
|
|
64
|
+
return function (event) {
|
|
65
|
+
var newRotation = _self._rotationControlLine.angle();
|
|
66
|
+
var rDiff = newRotation - _self.sector.ellipse.rotation;
|
|
67
|
+
_self.sector.ellipse.rotation = newRotation;
|
|
68
|
+
_self.sector.ellipse.axis.rotate(rDiff, _self.sector.ellipse.center);
|
|
69
|
+
_self.startAngleControlPoint.rotate(rDiff, _self.sector.ellipse.center);
|
|
70
|
+
_self.endAngleControlPoint.rotate(rDiff, _self.sector.ellipse.center);
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
VEllipseSectorHelper.prototype._handleDragStartAngleControlPoint = function () {
|
|
74
|
+
var _self = this;
|
|
75
|
+
return function (_event) {
|
|
76
|
+
// sector.startAngle = startAngleControlLine.angle() - sector.ellipse.rotation;
|
|
77
|
+
_self.sector.startAngle = geomutils_1.geomutils.mapAngleTo2PI(_self._startAngleControlLine.angle() - _self.sector.ellipse.rotation);
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
VEllipseSectorHelper.prototype._handleDragEndAngleControlPoint = function () {
|
|
81
|
+
var _self = this;
|
|
82
|
+
return function (event) {
|
|
83
|
+
_self.sector.endAngle = geomutils_1.geomutils.mapAngleTo2PI(_self._endAngleControlLine.angle() - _self.sector.ellipse.rotation);
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Draw grey handle lines.
|
|
88
|
+
*
|
|
89
|
+
* @param {DrawLib<any>} draw - The draw library instance to use.
|
|
90
|
+
* @param {DrawLib<any>} fill - The fill library instance to use.
|
|
91
|
+
*/
|
|
92
|
+
VEllipseSectorHelper.prototype.drawHandleLines = function (draw, fill) {
|
|
93
|
+
draw.line(this.sector.ellipse.center, this.startAngleControlPoint, "rgba(64,192,128,0.333)", 1.0, {
|
|
94
|
+
dashOffset: 0.0,
|
|
95
|
+
dashArray: [4, 2]
|
|
96
|
+
});
|
|
97
|
+
draw.line(this.sector.ellipse.center, this.endAngleControlPoint, "rgba(64,192,128,0.333)", 1.0, {
|
|
98
|
+
dashOffset: 0.0,
|
|
99
|
+
dashArray: [4, 2]
|
|
100
|
+
});
|
|
101
|
+
// Draw rotation handle line
|
|
102
|
+
draw.line(this.sector.ellipse.center, this.rotationControlPoint, "rgba(192,64,128,0.333)", 1.0, {
|
|
103
|
+
dashOffset: 0.0,
|
|
104
|
+
dashArray: [4, 2]
|
|
105
|
+
});
|
|
106
|
+
// Draw helper box
|
|
107
|
+
draw.line(this.sector.ellipse.center
|
|
108
|
+
.clone()
|
|
109
|
+
.add(0, this.sector.ellipse.signedRadiusV())
|
|
110
|
+
.rotate(this.sector.ellipse.rotation, this.sector.ellipse.center), this.sector.ellipse.axis, "rgba(64,128,192,0.333)", 1.0, {
|
|
111
|
+
dashOffset: 0.0,
|
|
112
|
+
dashArray: [4, 2]
|
|
113
|
+
});
|
|
114
|
+
draw.line(this.sector.ellipse.center
|
|
115
|
+
.clone()
|
|
116
|
+
.add(this.sector.ellipse.signedRadiusH(), 0)
|
|
117
|
+
.rotate(this.sector.ellipse.rotation, this.sector.ellipse.center), this.sector.ellipse.axis, "rgba(64,128,192,0.333)", 1.0, {
|
|
118
|
+
dashOffset: 0.0,
|
|
119
|
+
dashArray: [4, 2]
|
|
120
|
+
});
|
|
121
|
+
}; // END drawHandleLines
|
|
122
|
+
/**
|
|
123
|
+
* Destroy this VEllipseHandler which means: all listeners are being removed.
|
|
124
|
+
*/
|
|
125
|
+
VEllipseSectorHelper.prototype.destroy = function () {
|
|
126
|
+
this.sector.ellipse.center.listeners.removeDragListener(this._centerHandler);
|
|
127
|
+
this.rotationControlPoint.listeners.removeDragListener(this._rotationHandler);
|
|
128
|
+
this.startAngleControlPoint.listeners.removeDragListener(this._startAngleHandler);
|
|
129
|
+
this.endAngleControlPoint.listeners.removeDragListener(this._endAngleHandler);
|
|
130
|
+
};
|
|
49
131
|
return VEllipseSectorHelper;
|
|
50
132
|
}());
|
|
51
133
|
exports.VEllipseSectorHelper = VEllipseSectorHelper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VEllipseSectorHelper.js","sourceRoot":"","sources":["../../../ts/utils/helpers/VEllipseSectorHelper.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"VEllipseSectorHelper.js","sourceRoot":"","sources":["../../../ts/utils/helpers/VEllipseSectorHelper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,mCAAkC;AAIlC,6CAA4C;AAG5C;IAeE,8BACE,MAAsB,EACtB,sBAA8B,EAC9B,oBAA4B,EAC5B,oBAA4B;QAE5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QACrD,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QAEjD,2FAA2F;QAC3F,IAAI,CAAC,oBAAoB,GAAG,IAAI,WAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;QAClF,+FAA+F;QAC/F,IAAI,CAAC,sBAAsB,GAAG,IAAI,WAAI,C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AAE,CAAC,CAAC,EAAE,CAAC,CAAC;SAClB,CACF,CAAC;QACF,IAAI,CAAC,IAAI,CACP,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM;aACvB,KAAK,EAAE;aACP,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;aAC3C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EACnE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EACxB,wBAAwB,EACxB,GAAG,EACH;YACE,UAAU,EAAE,GAAG;YACf,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SAClB,CACF,CAAC;IACJ,CAAC,EAAC,sBAAsB;IAExB;;OAEG;IACH,sCAAO,GAAP;QACE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC7E,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC9E,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClF,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChF,CAAC;IACH,2BAAC;AAAD,CAAC,AA9JD,IA8JC;AA9JY,oDAAoB"}
|
|
@@ -235,7 +235,9 @@ function createDemoDrawables(pb, imagePath, drawCallback) {
|
|
|
235
235
|
var addEllipticSectorHelper = function (ellipticSector) {
|
|
236
236
|
var startControlPoint = ellipticSector.ellipse.vertAt(ellipticSector.startAngle);
|
|
237
237
|
var endControlPoint = ellipticSector.ellipse.vertAt(ellipticSector.endAngle);
|
|
238
|
-
var rotationControlPoint = ellipticSector.ellipse.vertAt(ellipticSector.rotation).scale(1.2, ellipticSector.ellipse.center);
|
|
238
|
+
// var rotationControlPoint = ellipticSector.ellipse.vertAt(ellipticSector.rotation).scale(1.2, ellipticSector.ellipse.center);
|
|
239
|
+
var rotationControlPoint = ellipticSector.ellipse.vertAt(0).scale(1.2, ellipticSector.ellipse.center);
|
|
240
|
+
|
|
239
241
|
new VEllipseSectorHelper(ellipticSector, startControlPoint, endControlPoint, rotationControlPoint);
|
|
240
242
|
pb.add(startControlPoint);
|
|
241
243
|
pb.add(endControlPoint);
|
package/src/esm/BezierPath.d.ts
CHANGED
|
@@ -25,15 +25,20 @@
|
|
|
25
25
|
* @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
26
26
|
* @modified 2023-10-06 Adding the `BezierPath.toPathPoints()` method.
|
|
27
27
|
* @modified 2023-10-07 Adding the `BezierPath.fromCurve(CubicBezierCurve)` static function.
|
|
28
|
-
* @
|
|
28
|
+
* @modified 2025-04-09 Added the `BezierPath.move` method to match the convention – which just calls `translate`.
|
|
29
|
+
* @modified 2025-04-09 Modified the `BezierPath.translate` method: chaning parameter `Vertex` to more generalized `XYCoords`.
|
|
30
|
+
* @modified 2025-04-14 Class `BezierPath` is now implementing interface `Intersectable`.
|
|
31
|
+
* @version 2.7.0
|
|
29
32
|
*
|
|
30
33
|
* @file BezierPath
|
|
31
34
|
* @public
|
|
32
35
|
**/
|
|
33
36
|
import { Bounds } from "./Bounds";
|
|
34
37
|
import { CubicBezierCurve } from "./CubicBezierCurve";
|
|
38
|
+
import { Vector } from "./Vector";
|
|
39
|
+
import { VertTuple } from "./VertTuple";
|
|
35
40
|
import { Vertex } from "./Vertex";
|
|
36
|
-
import { XYCoords, SVGSerializable, UID } from "./interfaces";
|
|
41
|
+
import { XYCoords, SVGSerializable, UID, Intersectable, IBounded } from "./interfaces";
|
|
37
42
|
/**
|
|
38
43
|
* @classdesc A BezierPath class.
|
|
39
44
|
*
|
|
@@ -47,7 +52,7 @@ import { XYCoords, SVGSerializable, UID } from "./interfaces";
|
|
|
47
52
|
* @requires UID
|
|
48
53
|
* @requires UIDGenerator
|
|
49
54
|
**/
|
|
50
|
-
export declare class BezierPath implements SVGSerializable {
|
|
55
|
+
export declare class BezierPath implements IBounded, Intersectable, SVGSerializable {
|
|
51
56
|
/**
|
|
52
57
|
* Required to generate proper CSS classes and other class related IDs.
|
|
53
58
|
**/
|
|
@@ -218,13 +223,24 @@ export declare class BezierPath implements SVGSerializable {
|
|
|
218
223
|
* Move the whole bezier path by the given (x,y)-amount.
|
|
219
224
|
*
|
|
220
225
|
* @method translate
|
|
221
|
-
* @param {
|
|
226
|
+
* @param {XYCoords} amount - The amount to be added (amount.x and amount.y)
|
|
222
227
|
* to each vertex of the curve.
|
|
223
228
|
* @instance
|
|
224
229
|
* @memberof BezierPath
|
|
225
230
|
* @return {BezierPath} this for chaining
|
|
226
231
|
**/
|
|
227
|
-
translate(amount:
|
|
232
|
+
translate(amount: XYCoords): BezierPath;
|
|
233
|
+
/**
|
|
234
|
+
* Move the whole bezier path by the given (x,y)-amount.
|
|
235
|
+
*
|
|
236
|
+
* @method move
|
|
237
|
+
* @param {XYCoords} amount - The amount to be added (amount.x and amount.y)
|
|
238
|
+
* to each vertex of the curve.
|
|
239
|
+
* @instance
|
|
240
|
+
* @memberof BezierPath
|
|
241
|
+
* @return {BezierPath} this for chaining
|
|
242
|
+
**/
|
|
243
|
+
move(amount: XYCoords): BezierPath;
|
|
228
244
|
/**
|
|
229
245
|
* Scale the whole bezier path by the given uniform factor.
|
|
230
246
|
*
|
|
@@ -333,6 +349,26 @@ export declare class BezierPath implements SVGSerializable {
|
|
|
333
349
|
* @return {Vertex} The perpendicluar vector at the relative path position.
|
|
334
350
|
**/
|
|
335
351
|
getPerpendicular(u: number): Vertex;
|
|
352
|
+
/**
|
|
353
|
+
* Get all line intersections with this shape.
|
|
354
|
+
*
|
|
355
|
+
* This method returns all intersections (as vertices) with this shape. The returned array of vertices is in no specific order.
|
|
356
|
+
*
|
|
357
|
+
* @param {VertTuple} line - The line to find intersections with.
|
|
358
|
+
* @param {boolean} inVectorBoundsOnly - If set to true only intersecion points on the passed vector are returned (located strictly between start and end vertex).
|
|
359
|
+
* @returns {Array<Vertex>} - An array of all intersections with the shape's outline.
|
|
360
|
+
*/
|
|
361
|
+
lineIntersections(line: VertTuple<any>, inVectorBoundsOnly?: boolean): Array<Vertex>;
|
|
362
|
+
/**
|
|
363
|
+
* Get all line intersections of this polygon and their tangents along the shape.
|
|
364
|
+
*
|
|
365
|
+
* This method returns all intersection tangents (as vectors) with this shape. The returned array of vectors is in no specific order.
|
|
366
|
+
*
|
|
367
|
+
* @param line
|
|
368
|
+
* @param lineIntersectionTangents
|
|
369
|
+
* @returns
|
|
370
|
+
*/
|
|
371
|
+
lineIntersectionTangents(line: VertTuple<any>, inVectorBoundsOnly?: boolean): Array<Vector>;
|
|
336
372
|
/**
|
|
337
373
|
* This is a helper function to locate the curve index for a given
|
|
338
374
|
* absolute path position u.
|
package/src/esm/BezierPath.js
CHANGED
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
* @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
26
26
|
* @modified 2023-10-06 Adding the `BezierPath.toPathPoints()` method.
|
|
27
27
|
* @modified 2023-10-07 Adding the `BezierPath.fromCurve(CubicBezierCurve)` static function.
|
|
28
|
-
* @
|
|
28
|
+
* @modified 2025-04-09 Added the `BezierPath.move` method to match the convention – which just calls `translate`.
|
|
29
|
+
* @modified 2025-04-09 Modified the `BezierPath.translate` method: chaning parameter `Vertex` to more generalized `XYCoords`.
|
|
30
|
+
* @modified 2025-04-14 Class `BezierPath` is now implementing interface `Intersectable`.
|
|
31
|
+
* @version 2.7.0
|
|
29
32
|
*
|
|
30
33
|
* @file BezierPath
|
|
31
34
|
* @public
|
|
@@ -234,7 +237,7 @@ export class BezierPath {
|
|
|
234
237
|
* Move the whole bezier path by the given (x,y)-amount.
|
|
235
238
|
*
|
|
236
239
|
* @method translate
|
|
237
|
-
* @param {
|
|
240
|
+
* @param {XYCoords} amount - The amount to be added (amount.x and amount.y)
|
|
238
241
|
* to each vertex of the curve.
|
|
239
242
|
* @instance
|
|
240
243
|
* @memberof BezierPath
|
|
@@ -253,6 +256,19 @@ export class BezierPath {
|
|
|
253
256
|
this.updateArcLengths();
|
|
254
257
|
return this;
|
|
255
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Move the whole bezier path by the given (x,y)-amount.
|
|
261
|
+
*
|
|
262
|
+
* @method move
|
|
263
|
+
* @param {XYCoords} amount - The amount to be added (amount.x and amount.y)
|
|
264
|
+
* to each vertex of the curve.
|
|
265
|
+
* @instance
|
|
266
|
+
* @memberof BezierPath
|
|
267
|
+
* @return {BezierPath} this for chaining
|
|
268
|
+
**/
|
|
269
|
+
move(amount) {
|
|
270
|
+
return this.translate(amount);
|
|
271
|
+
}
|
|
256
272
|
/**
|
|
257
273
|
* Scale the whole bezier path by the given uniform factor.
|
|
258
274
|
*
|
|
@@ -463,6 +479,36 @@ export class BezierPath {
|
|
|
463
479
|
var relativeU = u - uResult.uPart;
|
|
464
480
|
return bCurve.getPerpendicular(relativeU);
|
|
465
481
|
}
|
|
482
|
+
//--- BEGIN --- Implement interface `Intersectable`
|
|
483
|
+
/**
|
|
484
|
+
* Get all line intersections with this shape.
|
|
485
|
+
*
|
|
486
|
+
* This method returns all intersections (as vertices) with this shape. The returned array of vertices is in no specific order.
|
|
487
|
+
*
|
|
488
|
+
* @param {VertTuple} line - The line to find intersections with.
|
|
489
|
+
* @param {boolean} inVectorBoundsOnly - If set to true only intersecion points on the passed vector are returned (located strictly between start and end vertex).
|
|
490
|
+
* @returns {Array<Vertex>} - An array of all intersections with the shape's outline.
|
|
491
|
+
*/
|
|
492
|
+
lineIntersections(line, inVectorBoundsOnly = false) {
|
|
493
|
+
return this.bezierCurves.reduce((accu, curCurve) => {
|
|
494
|
+
return accu.concat(curCurve.lineIntersections(line, inVectorBoundsOnly));
|
|
495
|
+
}, []);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Get all line intersections of this polygon and their tangents along the shape.
|
|
499
|
+
*
|
|
500
|
+
* This method returns all intersection tangents (as vectors) with this shape. The returned array of vectors is in no specific order.
|
|
501
|
+
*
|
|
502
|
+
* @param line
|
|
503
|
+
* @param lineIntersectionTangents
|
|
504
|
+
* @returns
|
|
505
|
+
*/
|
|
506
|
+
lineIntersectionTangents(line, inVectorBoundsOnly = false) {
|
|
507
|
+
return this.bezierCurves.reduce((accu, curCurve) => {
|
|
508
|
+
return accu.concat(curCurve.lineIntersectionTangents(line, inVectorBoundsOnly));
|
|
509
|
+
}, []);
|
|
510
|
+
}
|
|
511
|
+
//--- END --- Implement interface `Intersectable`
|
|
466
512
|
/**
|
|
467
513
|
* This is a helper function to locate the curve index for a given
|
|
468
514
|
* absolute path position u.
|
|
@@ -676,6 +722,7 @@ export class BezierPath {
|
|
|
676
722
|
}
|
|
677
723
|
neighbourCurve.updateArcLengths();
|
|
678
724
|
}
|
|
725
|
+
//--- BEGIN --- Implement interface `IBounded`
|
|
679
726
|
/**
|
|
680
727
|
* Get the bounds of this Bézier path.
|
|
681
728
|
*
|
|
@@ -697,6 +744,7 @@ export class BezierPath {
|
|
|
697
744
|
}
|
|
698
745
|
return new Bounds(min, max);
|
|
699
746
|
}
|
|
747
|
+
//--- END --- Implement interface `IBounded`
|
|
700
748
|
/**
|
|
701
749
|
* Get n 'equally' distributed vertices along this Bézier path.
|
|
702
750
|
*
|