plotboilerplate 1.29.0 → 1.30.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/dist/index.esm.js +194 -16
- 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 +195 -16
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/Circle.d.ts +17 -1
- package/src/cjs/Circle.js +21 -1
- package/src/cjs/Circle.js.map +1 -1
- package/src/cjs/CubicBezierCurve.d.ts +34 -3
- package/src/cjs/CubicBezierCurve.js +79 -12
- package/src/cjs/CubicBezierCurve.js.map +1 -1
- package/src/cjs/Line.d.ts +46 -1
- package/src/cjs/Line.js +80 -1
- package/src/cjs/Line.js.map +1 -1
- package/src/cjs/VertTuple.d.ts +13 -2
- package/src/cjs/VertTuple.js +15 -2
- package/src/cjs/VertTuple.js.map +1 -1
- package/src/esm/Circle.d.ts +17 -1
- package/src/esm/Circle.js +21 -1
- package/src/esm/Circle.js.map +1 -1
- package/src/esm/CubicBezierCurve.d.ts +34 -3
- package/src/esm/CubicBezierCurve.js +79 -12
- package/src/esm/CubicBezierCurve.js.map +1 -1
- package/src/esm/Line.d.ts +46 -1
- package/src/esm/Line.js +80 -1
- package/src/esm/Line.js.map +1 -1
- package/src/esm/VertTuple.d.ts +13 -2
- package/src/esm/VertTuple.js +15 -2
- package/src/esm/VertTuple.js.map +1 -1
- package/src/index-gl.js +1 -2
- package/src/ts/Circle.ts +23 -1
- package/src/ts/CubicBezierCurve.ts +133 -48
- package/src/ts/Line.ts +84 -1
- package/src/ts/VertTuple.ts +16 -2
package/dist/index.esm.js
CHANGED
|
@@ -356,7 +356,8 @@ class VertexListeners {
|
|
|
356
356
|
* @modified 2026-07-08 Adding the `Circle.setRadius` method (for chaining).
|
|
357
357
|
* @mofified 2026-07-31 Adding the `radicalAxis(Circle)` method. Added the `Circle.circleUtils.createRadicalAxisHelperCircle` and `.circleDistance` helper methods.
|
|
358
358
|
* @modified 2026-08-03 Adding `Circle.tangentsFromPoint`.
|
|
359
|
-
* @
|
|
359
|
+
* @modified 2026-08-16 Adding the `Circle.sectorAngleByArcLength` method and the `Circle.circleUtils.sectorAngleByArcLength` helper method.
|
|
360
|
+
* @version 1.8.0
|
|
360
361
|
**/
|
|
361
362
|
/**
|
|
362
363
|
* @classdesc A simple circle: center point and radius.
|
|
@@ -731,6 +732,15 @@ class Circle {
|
|
|
731
732
|
}
|
|
732
733
|
return [new Vector(intersection.a, vert), new Vector(intersection.b, vert)];
|
|
733
734
|
}
|
|
735
|
+
/**
|
|
736
|
+
* Calculate inner sector angle for this circle and a given circle arc length.
|
|
737
|
+
*
|
|
738
|
+
* @param {number} sectorArcLength - The desired arc length (in units).
|
|
739
|
+
* @returns The sector's inner angle (in radians).
|
|
740
|
+
*/
|
|
741
|
+
sectorAngleByArcLength(sectorArcLength) {
|
|
742
|
+
return Circle.circleUtils.sectorAngleByArcLength(sectorArcLength, this.radius);
|
|
743
|
+
}
|
|
734
744
|
/**
|
|
735
745
|
* Create a deep copy of this circle.
|
|
736
746
|
*
|
|
@@ -809,6 +819,16 @@ Circle.circleUtils = {
|
|
|
809
819
|
*/
|
|
810
820
|
circleDistance: (circleA, circleB) => {
|
|
811
821
|
return circleA.center.distance(circleB.center) - circleA.radius - circleB.radius;
|
|
822
|
+
},
|
|
823
|
+
/**
|
|
824
|
+
* Calculate the inner sector angle for a given circle arc length and radius.
|
|
825
|
+
*
|
|
826
|
+
* @param {number} sectorArcLength - The desired arc length.
|
|
827
|
+
* @param {number} circleRadius - The circle's radius.
|
|
828
|
+
* @returns The sector angle in radians.
|
|
829
|
+
*/
|
|
830
|
+
sectorAngleByArcLength: (sectorArcLength, circleRadius) => {
|
|
831
|
+
return sectorArcLength / circleRadius;
|
|
812
832
|
}
|
|
813
833
|
};
|
|
814
834
|
|
|
@@ -2263,7 +2283,8 @@ Vertex$1.utils = {
|
|
|
2263
2283
|
* @modified 2025-04-15 Changed param of `VertTuple.moveTo` method from `Vertex` to `XYCoords`.
|
|
2264
2284
|
* @modified 2025-04-15 Added method `VertTuple.move` method.
|
|
2265
2285
|
* @modified 2026-06-10 Adding helper function `VertTuple.utils.calcCircumcircle`.
|
|
2266
|
-
* @
|
|
2286
|
+
* @modified 2026-06-17 Adding method `VertTuple.asLine` for converting Vector to Line instances.
|
|
2287
|
+
* @version 1.6.0
|
|
2267
2288
|
*/
|
|
2268
2289
|
/**
|
|
2269
2290
|
* @classdesc An abstract base classes for vertex tuple constructs, like Lines or Vectors.
|
|
@@ -2547,7 +2568,7 @@ class VertTuple {
|
|
|
2547
2568
|
/**
|
|
2548
2569
|
* Create a deep clone of this instance.
|
|
2549
2570
|
*
|
|
2550
|
-
* @method
|
|
2571
|
+
* @method clone
|
|
2551
2572
|
* @return {T} A type safe clone if this instance.
|
|
2552
2573
|
* @instance
|
|
2553
2574
|
* @memberof VertTuple
|
|
@@ -2555,6 +2576,17 @@ class VertTuple {
|
|
|
2555
2576
|
clone() {
|
|
2556
2577
|
return this.factory(this.a.clone(), this.b.clone());
|
|
2557
2578
|
}
|
|
2579
|
+
/**
|
|
2580
|
+
* Converts this `Vector` to a `Line` (segment).
|
|
2581
|
+
*
|
|
2582
|
+
* @method asLine
|
|
2583
|
+
* @return {T} A type safe clone if this instance.
|
|
2584
|
+
* @instance
|
|
2585
|
+
* @memberof VertTuple
|
|
2586
|
+
**/
|
|
2587
|
+
asLine() {
|
|
2588
|
+
return new Line(this.a, this.b);
|
|
2589
|
+
}
|
|
2558
2590
|
/**
|
|
2559
2591
|
* Create a string representation of this line.
|
|
2560
2592
|
*
|
|
@@ -2785,7 +2817,8 @@ Vector.utils = {
|
|
|
2785
2817
|
* @modified 2023-09-25 Changed param type of `intersection()` from Line to VertTuple.
|
|
2786
2818
|
* @modified 2025-04-15 Class `Line` now implements interface `Intersectable`.
|
|
2787
2819
|
* @modified 2025-04-16 Class `Line` now implements interface `IBounded`.
|
|
2788
|
-
* @
|
|
2820
|
+
* @modified 2026-08-16 Adding methods `Line.trimStart` and `Line.trimEnd`. Adding methods `Line.trimStartAt` and `Line.trimEndAt`.
|
|
2821
|
+
* @version 2.5.0
|
|
2789
2822
|
*
|
|
2790
2823
|
* @file Line
|
|
2791
2824
|
* @public
|
|
@@ -2912,6 +2945,84 @@ class Line extends VertTuple {
|
|
|
2912
2945
|
return this;
|
|
2913
2946
|
}
|
|
2914
2947
|
//--- END Implement PathSegment ---
|
|
2948
|
+
/**
|
|
2949
|
+
* Trim this line segment from the start point by the given amount.
|
|
2950
|
+
* The amount must be positive and should be withing the segment's length. If the amount exceeds the segment's length
|
|
2951
|
+
* then the length of the resulting line will be zero (0.0).
|
|
2952
|
+
*
|
|
2953
|
+
* @method trimStart
|
|
2954
|
+
* @memberof Line
|
|
2955
|
+
* @param {number} amount - The positive amount to trim the line from the start point `a`.
|
|
2956
|
+
* @returns {Line} This for chaining, with updated point `a`.
|
|
2957
|
+
*/
|
|
2958
|
+
trimStart(amount) {
|
|
2959
|
+
// Calculate the relative position `t` on this line.
|
|
2960
|
+
var t = amount / this.length();
|
|
2961
|
+
// `t` should be inside 0..1 – otherwise the amount was too large or negative.
|
|
2962
|
+
if (t < 0.0) {
|
|
2963
|
+
return this;
|
|
2964
|
+
}
|
|
2965
|
+
if (t > 1.0) {
|
|
2966
|
+
// Set the line to length zero (endpoint only)
|
|
2967
|
+
this.a = this.b.clone();
|
|
2968
|
+
return this;
|
|
2969
|
+
}
|
|
2970
|
+
this.a = this.vertAt(t);
|
|
2971
|
+
return this;
|
|
2972
|
+
}
|
|
2973
|
+
/**
|
|
2974
|
+
* Trim this line segment from the start point by the given relative amount.
|
|
2975
|
+
* The amount must be positive and should be within 0.0 and 1.0. If the amount exceeds the segment's length
|
|
2976
|
+
* then the length of the resulting line will be zero (0.0).
|
|
2977
|
+
*
|
|
2978
|
+
* @method trimStartAt
|
|
2979
|
+
* @memberof Line
|
|
2980
|
+
* @param {number} amount - The positive amount to trim the line from the start point `a`.
|
|
2981
|
+
* @returns {Line} This for chaining, with updated point `a`.
|
|
2982
|
+
*/
|
|
2983
|
+
trimStartAt(relativeAmount) {
|
|
2984
|
+
// Calculate the relative position `t` on this line.
|
|
2985
|
+
return this.trimStart(relativeAmount * this.length());
|
|
2986
|
+
}
|
|
2987
|
+
/**
|
|
2988
|
+
* Trim this line segment from the end point by the given amount.
|
|
2989
|
+
* The amount must be positive and should be withing the segment's length. If the amount exceeds the segment's length
|
|
2990
|
+
* then the length of the resulting line will be zero (0.0).
|
|
2991
|
+
*
|
|
2992
|
+
* @method trimEnd
|
|
2993
|
+
* @memberof Line
|
|
2994
|
+
* @param {number} amount - The positive amount to trim the line from the end point `b`.
|
|
2995
|
+
* @returns {Line} This for chaining, with updated point `b`.
|
|
2996
|
+
*/
|
|
2997
|
+
trimEnd(amount) {
|
|
2998
|
+
// Calculate the relative position `t` on this line.
|
|
2999
|
+
var t = 1.0 - amount / this.length();
|
|
3000
|
+
// `t` should be inside 0..1 – otherwise the amount was too large or negative.
|
|
3001
|
+
if (t < 0.0) {
|
|
3002
|
+
return this;
|
|
3003
|
+
}
|
|
3004
|
+
if (t > 1.0) {
|
|
3005
|
+
// Set the line to length zero (endpoint only)
|
|
3006
|
+
this.b = this.a.clone();
|
|
3007
|
+
return this;
|
|
3008
|
+
}
|
|
3009
|
+
this.b = this.vertAt(t);
|
|
3010
|
+
return this;
|
|
3011
|
+
}
|
|
3012
|
+
/**
|
|
3013
|
+
* Trim this line segment from the end point by the given relative amount.
|
|
3014
|
+
* The amount must be positive and should be within 0.0 and 1.0. If the amount exceeds the segment's length
|
|
3015
|
+
* then the length of the resulting line will be zero (0.0).
|
|
3016
|
+
*
|
|
3017
|
+
* @method trimEndAt
|
|
3018
|
+
* @memberof Line
|
|
3019
|
+
* @param {number} amount - The positive amount to trim the line from the start point `a`.
|
|
3020
|
+
* @returns {Line} This for chaining, with updated point `a`.
|
|
3021
|
+
*/
|
|
3022
|
+
trimEndAt(relativeAmount) {
|
|
3023
|
+
// Calculate the relative position `t` on this line.
|
|
3024
|
+
return this.trimEnd(relativeAmount * this.length());
|
|
3025
|
+
}
|
|
2915
3026
|
//--- BEGIN --- Implement interface `Intersectable`
|
|
2916
3027
|
/**
|
|
2917
3028
|
* Get all line intersections with this polygon.
|
|
@@ -4214,8 +4325,9 @@ class Bounds {
|
|
|
4214
4325
|
* @modified 2025-04-18 Added evaluation method for cubic Bézier curves `CubicBezierCurve.utils.evaluateT`.
|
|
4215
4326
|
* @modified 2025-04-18 Refactored method `CubicBezierCurve.getPointAt` to use `evaluateT`.
|
|
4216
4327
|
* @modified 2025-04-18 Fixed the `CubicBezierCurve.getBounds` method: now returning the real bounding box. Before it was an approximated one.
|
|
4217
|
-
* @modified 2025
|
|
4218
|
-
* @
|
|
4328
|
+
* @modified 2025-04-18 Added helper methods for bounding box calculation `CubucBezierCurve.util.cubicPolyMinMax` and `cubicPoly`.
|
|
4329
|
+
* @modified 2026-09-09 Adding methods `CubicBezierCurve.trimStartEnd` and `CubicBezierCurve.trimStartEndAt`.
|
|
4330
|
+
* @version 2.10.0
|
|
4219
4331
|
*
|
|
4220
4332
|
* @file CubicBezierCurve
|
|
4221
4333
|
* @public
|
|
@@ -4664,6 +4776,7 @@ class CubicBezierCurve {
|
|
|
4664
4776
|
this.endControlPoint.set(subCurbePoints[3]);
|
|
4665
4777
|
this.updateArcLengths();
|
|
4666
4778
|
return this;
|
|
4779
|
+
// return this.trimStartEndAt(t, null);
|
|
4667
4780
|
}
|
|
4668
4781
|
/**
|
|
4669
4782
|
* Trim off the end of this curve. The position parameter `uValue` is the absolute position on the
|
|
@@ -4699,7 +4812,79 @@ class CubicBezierCurve {
|
|
|
4699
4812
|
this.endControlPoint.set(subCurbePoints[3]);
|
|
4700
4813
|
this.updateArcLengths();
|
|
4701
4814
|
return this;
|
|
4815
|
+
// return this.trimStartEndAt(null, t);
|
|
4702
4816
|
}
|
|
4817
|
+
/**
|
|
4818
|
+
* Trim off a start and end section of this curve. The position parameters `uStart` and `uEnd` are the absolute positions in [0..arcLength].
|
|
4819
|
+
* The remaining curve will be the one in the bounds `[uStart,uEnd]` (so `[0.0,uStart]` and `[uEnd,1.0]` are cut off).
|
|
4820
|
+
*
|
|
4821
|
+
* Parameters out of bounds (< 0.0 or > arcLength) are ignored.
|
|
4822
|
+
* If `uEnd` is smaller than `uStart` then a curve with length zero (0) at `uStart` is returned.
|
|
4823
|
+
*
|
|
4824
|
+
* @method trimStartEndAt
|
|
4825
|
+
* @instance
|
|
4826
|
+
* @memberof CubicBezierCurve
|
|
4827
|
+
* @param {number} tStart - The relative position parameter where to cut off the head curve.
|
|
4828
|
+
* @param {number} tEnd - The relative position parameter where to cut off the tail curve.
|
|
4829
|
+
* @returns {CubicBezierCurve} `this` for chanining.
|
|
4830
|
+
*/
|
|
4831
|
+
trimStartEnd(uStart, uEnd) {
|
|
4832
|
+
return this.trimStartEndAt(this.convertU2T(uStart), this.convertU2T(uEnd));
|
|
4833
|
+
}
|
|
4834
|
+
/**
|
|
4835
|
+
* Trim off a start and end section of this curve. The position parameters `tStart` and `tEnd` are the relative positions in [0..1].
|
|
4836
|
+
* The remaining curve will be the one in the bounds `[tStart,tEnd]` (so `[0.0,tStart]` and `[tEnd,1.0]` are cut off).
|
|
4837
|
+
*
|
|
4838
|
+
* Parameters out of bounds (< 0.0 or > 1.0) are ignored.
|
|
4839
|
+
* If `tEnd` is smaller than `tStart` then a curve with length zero (0) at `tStart` is returned.
|
|
4840
|
+
*
|
|
4841
|
+
* @method trimStartEndAt
|
|
4842
|
+
* @instance
|
|
4843
|
+
* @memberof CubicBezierCurve
|
|
4844
|
+
* @param {number} tStart - The relative position parameter where to cut off the head curve.
|
|
4845
|
+
* @param {number} tEnd - The relative position parameter where to cut off the tail curve.
|
|
4846
|
+
* @returns {CubicBezierCurve} `this` for chanining.
|
|
4847
|
+
*/
|
|
4848
|
+
trimStartEndAt(tStart, tEnd) {
|
|
4849
|
+
const cleanTrimStart = Math.min(Math.max(0.0, tStart), 1.0);
|
|
4850
|
+
const cleanTrimEnd = Math.min(Math.max(cleanTrimStart, tEnd), 1.0);
|
|
4851
|
+
this.trimStartAt(cleanTrimStart);
|
|
4852
|
+
const relativeTrimEnd = (cleanTrimEnd - cleanTrimStart) / (1.0 - cleanTrimStart);
|
|
4853
|
+
this.trimEndAt(relativeTrimEnd);
|
|
4854
|
+
return this;
|
|
4855
|
+
}
|
|
4856
|
+
// __trimStartEndAt(tStart: number, tEnd: number): CubicBezierCurve {
|
|
4857
|
+
// var finalCurvePoints = [
|
|
4858
|
+
// this.startPoint.clone(),
|
|
4859
|
+
// this.endPoint.clone(),
|
|
4860
|
+
// this.startControlPoint.clone(),
|
|
4861
|
+
// this.endControlPoint.clone()
|
|
4862
|
+
// ];
|
|
4863
|
+
// if (typeof tStart === "number" && !Number.isNaN(tStart)) {
|
|
4864
|
+
// const subCurvePointsStart = CubicBezierCurve.utils.getSubCurvePointsAt(this, tStart, 1.0);
|
|
4865
|
+
// finalCurvePoints[0].set(subCurvePointsStart[0]);
|
|
4866
|
+
// finalCurvePoints[2].set(subCurvePointsStart[2]);
|
|
4867
|
+
// // this.startPoint.set(subCurvePointsStart[0]);
|
|
4868
|
+
// // this.startControlPoint.set(subCurvePointsStart[2]);
|
|
4869
|
+
// // this.endPoint.set(subCurvePointsStart[1]);
|
|
4870
|
+
// // this.endControlPoint.set(subCurvePointsStart[3]);
|
|
4871
|
+
// }
|
|
4872
|
+
// if (typeof tEnd === "number" && !Number.isNaN(tEnd)) {
|
|
4873
|
+
// const subCurvePointsEnd = CubicBezierCurve.utils.getSubCurvePointsAt(this, 0.0, tEnd);
|
|
4874
|
+
// // this.startPoint.set(subCurvePointsEnd[0]);
|
|
4875
|
+
// // this.startControlPoint.set(subCurvePointsEnd[2]);
|
|
4876
|
+
// // this.endPoint.set(subCurvePointsEnd[1]);
|
|
4877
|
+
// // this.endControlPoint.set(subCurvePointsEnd[3]);
|
|
4878
|
+
// finalCurvePoints[1].set(subCurvePointsEnd[1]);
|
|
4879
|
+
// finalCurvePoints[3].set(subCurvePointsEnd[3]);
|
|
4880
|
+
// }
|
|
4881
|
+
// this.startPoint.set(finalCurvePoints[0]);
|
|
4882
|
+
// this.endPoint.set(finalCurvePoints[1]);
|
|
4883
|
+
// this.startControlPoint.set(finalCurvePoints[2]);
|
|
4884
|
+
// this.endControlPoint.set(finalCurvePoints[3]);
|
|
4885
|
+
// this.updateArcLengths();
|
|
4886
|
+
// return this;
|
|
4887
|
+
// }
|
|
4703
4888
|
/**
|
|
4704
4889
|
* Get a sub curve at the given start end end positions (values on the curve's length, between 0 and curve.arcLength).
|
|
4705
4890
|
*
|
|
@@ -5051,10 +5236,7 @@ CubicBezierCurve.END_POINT = 3;
|
|
|
5051
5236
|
*/
|
|
5052
5237
|
CubicBezierCurve.utils = {
|
|
5053
5238
|
evaluateT: (p0, p1, p2, p3, t) => {
|
|
5054
|
-
return p0 * Math.pow(1.0 - t, 3) +
|
|
5055
|
-
p1 * 3 * t * Math.pow(1.0 - t, 2) +
|
|
5056
|
-
p2 * 3 * Math.pow(t, 2) * (1.0 - t) +
|
|
5057
|
-
p3 * Math.pow(t, 3);
|
|
5239
|
+
return (p0 * Math.pow(1.0 - t, 3) + p1 * 3 * t * Math.pow(1.0 - t, 2) + p2 * 3 * Math.pow(t, 2) * (1.0 - t) + p3 * Math.pow(t, 3));
|
|
5058
5240
|
},
|
|
5059
5241
|
cubicPolyMinMax: (p0, p1, p2, p3) => {
|
|
5060
5242
|
// var polyX = CubicBezierCurve.utils.cubicPoly2(
|
|
@@ -5126,7 +5308,7 @@ CubicBezierCurve.utils = {
|
|
|
5126
5308
|
* @param {number} tEnd – The end offset if the desired cub curve (must be in [0..1]).
|
|
5127
5309
|
* @instance
|
|
5128
5310
|
* @memberof CubicBezierCurve
|
|
5129
|
-
* @return {
|
|
5311
|
+
* @return {[Vertex, Vertex, Vertex, Vertex]} The sub curve as curve vertices.
|
|
5130
5312
|
**/
|
|
5131
5313
|
getSubCurvePointsAt: (curve, tStart, tEnd) => {
|
|
5132
5314
|
const startVec = new Vector(curve.getPointAt(tStart), curve.getTangentAt(tStart));
|
|
@@ -5215,11 +5397,7 @@ CubicBezierCurve.utils = {
|
|
|
5215
5397
|
* @returns {[number,number,number]}
|
|
5216
5398
|
*/
|
|
5217
5399
|
cubicPoly: (p0, p1, p2, p3) => {
|
|
5218
|
-
return [
|
|
5219
|
-
3 * p3 - 9 * p2 + 9 * p1 - 3 * p0,
|
|
5220
|
-
6 * p0 - 12 * p1 + 6 * p2,
|
|
5221
|
-
3 * p1 - 3 * p0
|
|
5222
|
-
];
|
|
5400
|
+
return [3 * p3 - 9 * p2 + 9 * p1 - 3 * p0, 6 * p0 - 12 * p1 + 6 * p2, 3 * p1 - 3 * p0];
|
|
5223
5401
|
},
|
|
5224
5402
|
/**
|
|
5225
5403
|
* sign of number, but is division safe: no zero returned :)
|