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/src/esm/Line.js CHANGED
@@ -18,7 +18,8 @@
18
18
  * @modified 2023-09-25 Changed param type of `intersection()` from Line to VertTuple.
19
19
  * @modified 2025-04-15 Class `Line` now implements interface `Intersectable`.
20
20
  * @modified 2025-04-16 Class `Line` now implements interface `IBounded`.
21
- * @version 2.4.0
21
+ * @modified 2026-08-16 Adding methods `Line.trimStart` and `Line.trimEnd`. Adding methods `Line.trimStartAt` and `Line.trimEndAt`.
22
+ * @version 2.5.0
22
23
  *
23
24
  * @file Line
24
25
  * @public
@@ -149,6 +150,84 @@ export class Line extends VertTuple {
149
150
  return this;
150
151
  }
151
152
  //--- END Implement PathSegment ---
153
+ /**
154
+ * Trim this line segment from the start point by the given amount.
155
+ * The amount must be positive and should be withing the segment's length. If the amount exceeds the segment's length
156
+ * then the length of the resulting line will be zero (0.0).
157
+ *
158
+ * @method trimStart
159
+ * @memberof Line
160
+ * @param {number} amount - The positive amount to trim the line from the start point `a`.
161
+ * @returns {Line} This for chaining, with updated point `a`.
162
+ */
163
+ trimStart(amount) {
164
+ // Calculate the relative position `t` on this line.
165
+ var t = amount / this.length();
166
+ // `t` should be inside 0..1 – otherwise the amount was too large or negative.
167
+ if (t < 0.0) {
168
+ return this;
169
+ }
170
+ if (t > 1.0) {
171
+ // Set the line to length zero (endpoint only)
172
+ this.a = this.b.clone();
173
+ return this;
174
+ }
175
+ this.a = this.vertAt(t);
176
+ return this;
177
+ }
178
+ /**
179
+ * Trim this line segment from the start point by the given relative amount.
180
+ * The amount must be positive and should be within 0.0 and 1.0. If the amount exceeds the segment's length
181
+ * then the length of the resulting line will be zero (0.0).
182
+ *
183
+ * @method trimStartAt
184
+ * @memberof Line
185
+ * @param {number} amount - The positive amount to trim the line from the start point `a`.
186
+ * @returns {Line} This for chaining, with updated point `a`.
187
+ */
188
+ trimStartAt(relativeAmount) {
189
+ // Calculate the relative position `t` on this line.
190
+ return this.trimStart(relativeAmount * this.length());
191
+ }
192
+ /**
193
+ * Trim this line segment from the end point by the given amount.
194
+ * The amount must be positive and should be withing the segment's length. If the amount exceeds the segment's length
195
+ * then the length of the resulting line will be zero (0.0).
196
+ *
197
+ * @method trimEnd
198
+ * @memberof Line
199
+ * @param {number} amount - The positive amount to trim the line from the end point `b`.
200
+ * @returns {Line} This for chaining, with updated point `b`.
201
+ */
202
+ trimEnd(amount) {
203
+ // Calculate the relative position `t` on this line.
204
+ var t = 1.0 - amount / this.length();
205
+ // `t` should be inside 0..1 – otherwise the amount was too large or negative.
206
+ if (t < 0.0) {
207
+ return this;
208
+ }
209
+ if (t > 1.0) {
210
+ // Set the line to length zero (endpoint only)
211
+ this.b = this.a.clone();
212
+ return this;
213
+ }
214
+ this.b = this.vertAt(t);
215
+ return this;
216
+ }
217
+ /**
218
+ * Trim this line segment from the end point by the given relative amount.
219
+ * The amount must be positive and should be within 0.0 and 1.0. If the amount exceeds the segment's length
220
+ * then the length of the resulting line will be zero (0.0).
221
+ *
222
+ * @method trimEndAt
223
+ * @memberof Line
224
+ * @param {number} amount - The positive amount to trim the line from the start point `a`.
225
+ * @returns {Line} This for chaining, with updated point `a`.
226
+ */
227
+ trimEndAt(relativeAmount) {
228
+ // Calculate the relative position `t` on this line.
229
+ return this.trimEnd(relativeAmount * this.length());
230
+ }
152
231
  //--- BEGIN --- Implement interface `Intersectable`
153
232
  /**
154
233
  * Get all line intersections with this polygon.
@@ -1 +1 @@
1
- {"version":3,"file":"Line.js","sourceRoot":"","sources":["../ts/Line.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;IAwBI;AAEJ,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAA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AC,CAAC;IACjF,CAAC;CAEF"}
@@ -17,11 +17,13 @@
17
17
  * @modified 2025-04-15 Changed param of `VertTuple.moveTo` method from `Vertex` to `XYCoords`.
18
18
  * @modified 2025-04-15 Added method `VertTuple.move` method.
19
19
  * @modified 2026-06-10 Adding helper function `VertTuple.utils.calcCircumcircle`.
20
- * @version 1.5.0
20
+ * @modified 2026-06-17 Adding method `VertTuple.asLine` for converting Vector to Line instances.
21
+ * @version 1.6.0
21
22
  */
22
23
  import { Vertex } from "./Vertex";
23
24
  import { XYCoords, UID } from "./interfaces";
24
25
  import { ICircle } from "./Circle";
26
+ import { Line } from "./Line";
25
27
  /**
26
28
  * @classdesc An abstract base classes for vertex tuple constructs, like Lines or Vectors.
27
29
  * @abstract
@@ -256,12 +258,21 @@ export declare class VertTuple<T extends VertTuple<T>> {
256
258
  /**
257
259
  * Create a deep clone of this instance.
258
260
  *
259
- * @method cloneLine
261
+ * @method clone
260
262
  * @return {T} A type safe clone if this instance.
261
263
  * @instance
262
264
  * @memberof VertTuple
263
265
  **/
264
266
  clone(): T;
267
+ /**
268
+ * Converts this `Vector` to a `Line` (segment).
269
+ *
270
+ * @method asLine
271
+ * @return {T} A type safe clone if this instance.
272
+ * @instance
273
+ * @memberof VertTuple
274
+ **/
275
+ asLine(): Line;
265
276
  /**
266
277
  * Create a string representation of this line.
267
278
  *
@@ -17,10 +17,12 @@
17
17
  * @modified 2025-04-15 Changed param of `VertTuple.moveTo` method from `Vertex` to `XYCoords`.
18
18
  * @modified 2025-04-15 Added method `VertTuple.move` method.
19
19
  * @modified 2026-06-10 Adding helper function `VertTuple.utils.calcCircumcircle`.
20
- * @version 1.5.0
20
+ * @modified 2026-06-17 Adding method `VertTuple.asLine` for converting Vector to Line instances.
21
+ * @version 1.6.0
21
22
  */
22
23
  import { Vertex } from "./Vertex";
23
24
  import { UIDGenerator } from "./UIDGenerator";
25
+ import { Line } from "./Line";
24
26
  /**
25
27
  * @classdesc An abstract base classes for vertex tuple constructs, like Lines or Vectors.
26
28
  * @abstract
@@ -303,7 +305,7 @@ export class VertTuple {
303
305
  /**
304
306
  * Create a deep clone of this instance.
305
307
  *
306
- * @method cloneLine
308
+ * @method clone
307
309
  * @return {T} A type safe clone if this instance.
308
310
  * @instance
309
311
  * @memberof VertTuple
@@ -311,6 +313,17 @@ export class VertTuple {
311
313
  clone() {
312
314
  return this.factory(this.a.clone(), this.b.clone());
313
315
  }
316
+ /**
317
+ * Converts this `Vector` to a `Line` (segment).
318
+ *
319
+ * @method asLine
320
+ * @return {T} A type safe clone if this instance.
321
+ * @instance
322
+ * @memberof VertTuple
323
+ **/
324
+ asLine() {
325
+ return new Line(this.a, this.b);
326
+ }
314
327
  /**
315
328
  * Create a string representation of this line.
316
329
  *
@@ -1 +1 @@
1
- {"version":3,"file":"VertTuple.js","sourceRoot":"","sources":["../ts/VertTuple.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C;;;;;;GAMG;AACH,MAAM,OAAO,SAAS;IAsCpB;;;;;;;QAOI;IACJ,YAAY,CAAS,EAAE,CAAS,EAAE,OAAoC;QACpE,IAAI,CAAC,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;;QAMI;IACJ,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,I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GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,EACtB,EAAE,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;QAEzB,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;IAC5G,CAAC;CACF,CAAC"}
package/src/index-gl.js CHANGED
@@ -16,7 +16,6 @@
16
16
  // Fetch the GET params
17
17
  let GUP = gup();
18
18
  var isDarkmode = detectDarkMode(GUP);
19
- var isDarkmode = detectDarkMode(GUP);
20
19
 
21
20
  window.addEventListener("load", function () {
22
21
  // All config params are optional.
@@ -91,7 +90,7 @@
91
90
  });
92
91
 
93
92
  // Use a helper function to build all demo-drawables.
94
- var drawables = createDemoDrawables(pb.canvasSize, "example-image.png", function () {
93
+ var drawables = createDemoDrawables(pb, "example-image.png", function () {
95
94
  pb.redraw();
96
95
  });
97
96
  pb.add(drawables);
package/src/ts/Circle.ts CHANGED
@@ -22,7 +22,8 @@
22
22
  * @modified 2026-07-08 Adding the `Circle.setRadius` method (for chaining).
23
23
  * @mofified 2026-07-31 Adding the `radicalAxis(Circle)` method. Added the `Circle.circleUtils.createRadicalAxisHelperCircle` and `.circleDistance` helper methods.
24
24
  * @modified 2026-08-03 Adding `Circle.tangentsFromPoint`.
25
- * @version 1.7.0
25
+ * @modified 2026-08-16 Adding the `Circle.sectorAngleByArcLength` method and the `Circle.circleUtils.sectorAngleByArcLength` helper method.
26
+ * @version 1.8.0
26
27
  **/
27
28
 
28
29
  import { Bounds } from "./Bounds";
@@ -474,6 +475,16 @@ export class Circle implements IBounded, ICircle, Intersectable, SVGSerializable
474
475
  return [new Vector(intersection.a, vert), new Vector(intersection.b, vert)];
475
476
  }
476
477
 
478
+ /**
479
+ * Calculate inner sector angle for this circle and a given circle arc length.
480
+ *
481
+ * @param {number} sectorArcLength - The desired arc length (in units).
482
+ * @returns The sector's inner angle (in radians).
483
+ */
484
+ sectorAngleByArcLength(sectorArcLength: number) {
485
+ return Circle.circleUtils.sectorAngleByArcLength(sectorArcLength, this.radius);
486
+ }
487
+
477
488
  /**
478
489
  * Create a deep copy of this circle.
479
490
  *
@@ -558,6 +569,17 @@ export class Circle implements IBounded, ICircle, Intersectable, SVGSerializable
558
569
  */
559
570
  circleDistance: (circleA: Circle, circleB: Circle): number => {
560
571
  return circleA.center.distance(circleB.center) - circleA.radius - circleB.radius;
572
+ },
573
+
574
+ /**
575
+ * Calculate the inner sector angle for a given circle arc length and radius.
576
+ *
577
+ * @param {number} sectorArcLength - The desired arc length.
578
+ * @param {number} circleRadius - The circle's radius.
579
+ * @returns The sector angle in radians.
580
+ */
581
+ sectorAngleByArcLength: (sectorArcLength: number, circleRadius: number) => {
582
+ return sectorArcLength / circleRadius;
561
583
  }
562
584
  };
563
585
  } // END class
@@ -32,8 +32,9 @@
32
32
  * @modified 2025-04-18 Added evaluation method for cubic Bézier curves `CubicBezierCurve.utils.evaluateT`.
33
33
  * @modified 2025-04-18 Refactored method `CubicBezierCurve.getPointAt` to use `evaluateT`.
34
34
  * @modified 2025-04-18 Fixed the `CubicBezierCurve.getBounds` method: now returning the real bounding box. Before it was an approximated one.
35
- * @modified 2025-ß4-18 Added helper methods for bounding box calculation `CubucBezierCurve.util.cubicPolyMinMax` and `cubicPoly`.
36
- * @version 2.9.0
35
+ * @modified 2025-04-18 Added helper methods for bounding box calculation `CubucBezierCurve.util.cubicPolyMinMax` and `cubicPoly`.
36
+ * @modified 2026-09-09 Adding methods `CubicBezierCurve.trimStartEnd` and `CubicBezierCurve.trimStartEndAt`.
37
+ * @version 2.10.0
37
38
  *
38
39
  * @file CubicBezierCurve
39
40
  * @public
@@ -401,30 +402,30 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
401
402
  // Thanks to Richard "RM" for the Bézier bounds calculatin
402
403
  // https://jsfiddle.net/SalixAlba/QQnvm/4/
403
404
 
404
- const xMinMax = CubicBezierCurve.utils.cubicPolyMinMax(
405
- this.startPoint.x,
406
- this.startControlPoint.x,
407
- this.endControlPoint.x,
408
- this.endPoint.x
409
- );
410
- const xl = xMinMax.min;
411
- const xh = xMinMax.max;
412
-
413
- const yMinMax = CubicBezierCurve.utils.cubicPolyMinMax(
414
- this.startPoint.y,
415
- this.startControlPoint.y,
416
- this.endControlPoint.y,
417
- this.endPoint.y
418
- );
419
- const yl = yMinMax.min;
420
- const yh = yMinMax.max;
421
-
422
- return Bounds.computeFromVertices([
423
- { x: xl, y: yl },
424
- { x: xl, y: yh },
425
- { x: xh, y: yh },
426
- { x: xh, y: yl }
427
- ]);
405
+ const xMinMax = CubicBezierCurve.utils.cubicPolyMinMax(
406
+ this.startPoint.x,
407
+ this.startControlPoint.x,
408
+ this.endControlPoint.x,
409
+ this.endPoint.x
410
+ );
411
+ const xl = xMinMax.min;
412
+ const xh = xMinMax.max;
413
+
414
+ const yMinMax = CubicBezierCurve.utils.cubicPolyMinMax(
415
+ this.startPoint.y,
416
+ this.startControlPoint.y,
417
+ this.endControlPoint.y,
418
+ this.endPoint.y
419
+ );
420
+ const yl = yMinMax.min;
421
+ const yh = yMinMax.max;
422
+
423
+ return Bounds.computeFromVertices([
424
+ { x: xl, y: yl },
425
+ { x: xl, y: yh },
426
+ { x: xh, y: yh },
427
+ { x: xh, y: yl }
428
+ ]);
428
429
  }
429
430
  //--- END --- Implement interface `IBounded`
430
431
 
@@ -526,8 +527,20 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
526
527
  // this.startControlPoint.y * 3 * t * Math.pow(1.0 - t, 2) +
527
528
  // this.endControlPoint.y * 3 * Math.pow(t, 2) * (1.0 - t) +
528
529
  // this.endPoint.y * Math.pow(t, 3);
529
- const x: number = CubicBezierCurve.utils.evaluateT(this.startPoint.x, this.startControlPoint.x, this.endControlPoint.x, this.endPoint.x, t);
530
- const y: number = CubicBezierCurve.utils.evaluateT(this.startPoint.y, this.startControlPoint.y, this.endControlPoint.y, this.endPoint.y, t);
530
+ const x: number = CubicBezierCurve.utils.evaluateT(
531
+ this.startPoint.x,
532
+ this.startControlPoint.x,
533
+ this.endControlPoint.x,
534
+ this.endPoint.x,
535
+ t
536
+ );
537
+ const y: number = CubicBezierCurve.utils.evaluateT(
538
+ this.startPoint.y,
539
+ this.startControlPoint.y,
540
+ this.endControlPoint.y,
541
+ this.endPoint.y,
542
+ t
543
+ );
531
544
  return new Vertex(x, y);
532
545
  }
533
546
 
@@ -611,6 +624,7 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
611
624
  this.endControlPoint.set(subCurbePoints[3]);
612
625
  this.updateArcLengths();
613
626
  return this;
627
+ // return this.trimStartEndAt(t, null);
614
628
  }
615
629
 
616
630
  /**
@@ -648,8 +662,88 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
648
662
  this.endControlPoint.set(subCurbePoints[3]);
649
663
  this.updateArcLengths();
650
664
  return this;
665
+ // return this.trimStartEndAt(null, t);
651
666
  }
652
667
 
668
+ /**
669
+ * Trim off a start and end section of this curve. The position parameters `uStart` and `uEnd` are the absolute positions in [0..arcLength].
670
+ * The remaining curve will be the one in the bounds `[uStart,uEnd]` (so `[0.0,uStart]` and `[uEnd,1.0]` are cut off).
671
+ *
672
+ * Parameters out of bounds (< 0.0 or > arcLength) are ignored.
673
+ * If `uEnd` is smaller than `uStart` then a curve with length zero (0) at `uStart` is returned.
674
+ *
675
+ * @method trimStartEndAt
676
+ * @instance
677
+ * @memberof CubicBezierCurve
678
+ * @param {number} tStart - The relative position parameter where to cut off the head curve.
679
+ * @param {number} tEnd - The relative position parameter where to cut off the tail curve.
680
+ * @returns {CubicBezierCurve} `this` for chanining.
681
+ */
682
+
683
+ trimStartEnd(uStart: number, uEnd: number): CubicBezierCurve {
684
+ return this.trimStartEndAt(this.convertU2T(uStart), this.convertU2T(uEnd));
685
+ }
686
+
687
+ /**
688
+ * Trim off a start and end section of this curve. The position parameters `tStart` and `tEnd` are the relative positions in [0..1].
689
+ * The remaining curve will be the one in the bounds `[tStart,tEnd]` (so `[0.0,tStart]` and `[tEnd,1.0]` are cut off).
690
+ *
691
+ * Parameters out of bounds (< 0.0 or > 1.0) are ignored.
692
+ * If `tEnd` is smaller than `tStart` then a curve with length zero (0) at `tStart` is returned.
693
+ *
694
+ * @method trimStartEndAt
695
+ * @instance
696
+ * @memberof CubicBezierCurve
697
+ * @param {number} tStart - The relative position parameter where to cut off the head curve.
698
+ * @param {number} tEnd - The relative position parameter where to cut off the tail curve.
699
+ * @returns {CubicBezierCurve} `this` for chanining.
700
+ */
701
+
702
+ trimStartEndAt(tStart: number, tEnd: number): CubicBezierCurve {
703
+ const cleanTrimStart = Math.min(Math.max(0.0, tStart), 1.0);
704
+ const cleanTrimEnd = Math.min(Math.max(cleanTrimStart, tEnd), 1.0);
705
+ this.trimStartAt(cleanTrimStart);
706
+ const relativeTrimEnd = (cleanTrimEnd - cleanTrimStart) / (1.0 - cleanTrimStart);
707
+ this.trimEndAt(relativeTrimEnd);
708
+ return this;
709
+ }
710
+
711
+ // __trimStartEndAt(tStart: number, tEnd: number): CubicBezierCurve {
712
+ // var finalCurvePoints = [
713
+ // this.startPoint.clone(),
714
+ // this.endPoint.clone(),
715
+ // this.startControlPoint.clone(),
716
+ // this.endControlPoint.clone()
717
+ // ];
718
+ // if (typeof tStart === "number" && !Number.isNaN(tStart)) {
719
+ // const subCurvePointsStart = CubicBezierCurve.utils.getSubCurvePointsAt(this, tStart, 1.0);
720
+ // finalCurvePoints[0].set(subCurvePointsStart[0]);
721
+ // finalCurvePoints[2].set(subCurvePointsStart[2]);
722
+ // // this.startPoint.set(subCurvePointsStart[0]);
723
+ // // this.startControlPoint.set(subCurvePointsStart[2]);
724
+ // // this.endPoint.set(subCurvePointsStart[1]);
725
+ // // this.endControlPoint.set(subCurvePointsStart[3]);
726
+ // }
727
+
728
+ // if (typeof tEnd === "number" && !Number.isNaN(tEnd)) {
729
+ // const subCurvePointsEnd = CubicBezierCurve.utils.getSubCurvePointsAt(this, 0.0, tEnd);
730
+ // // this.startPoint.set(subCurvePointsEnd[0]);
731
+ // // this.startControlPoint.set(subCurvePointsEnd[2]);
732
+ // // this.endPoint.set(subCurvePointsEnd[1]);
733
+ // // this.endControlPoint.set(subCurvePointsEnd[3]);
734
+ // finalCurvePoints[1].set(subCurvePointsEnd[1]);
735
+ // finalCurvePoints[3].set(subCurvePointsEnd[3]);
736
+ // }
737
+
738
+ // this.startPoint.set(finalCurvePoints[0]);
739
+ // this.endPoint.set(finalCurvePoints[1]);
740
+ // this.startControlPoint.set(finalCurvePoints[2]);
741
+ // this.endControlPoint.set(finalCurvePoints[3]);
742
+
743
+ // this.updateArcLengths();
744
+ // return this;
745
+ // }
746
+
653
747
  /**
654
748
  * Get a sub curve at the given start end end positions (values on the curve's length, between 0 and curve.arcLength).
655
749
  *
@@ -1027,15 +1121,13 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
1027
1121
  * Helper utils.
1028
1122
  */
1029
1123
  public static utils = {
1030
-
1031
- evaluateT: (p0:number, p1:number, p2:number, p3:number, t:number) : number => {
1032
- return p0 * Math.pow(1.0 - t, 3) +
1033
- p1 * 3 * t * Math.pow(1.0 - t, 2) +
1034
- p2 * 3 * Math.pow(t, 2) * (1.0 - t) +
1035
- p3 * Math.pow(t, 3);
1124
+ evaluateT: (p0: number, p1: number, p2: number, p3: number, t: number): number => {
1125
+ return (
1126
+ 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)
1127
+ );
1036
1128
  },
1037
1129
 
1038
- cubicPolyMinMax: (p0:number, p1:number, p2:number, p3:number) : { min: number, max: number }=> {
1130
+ cubicPolyMinMax: (p0: number, p1: number, p2: number, p3: number): { min: number; max: number } => {
1039
1131
  // var polyX = CubicBezierCurve.utils.cubicPoly2(
1040
1132
  // p0, // P[0].X, // bezierCurve.startPoint.x,
1041
1133
  // p1, // P[1].X, // bezierCurve.startControlPoint.x,
@@ -1048,7 +1140,6 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
1048
1140
  // var c = polyX.c;
1049
1141
  // var disc = polyX.b * polyX.b - 4 * polyX.a * polyX.c;
1050
1142
 
1051
-
1052
1143
  var polyX = CubicBezierCurve.utils.cubicPoly(
1053
1144
  p0, // P[0].X, // bezierCurve.startPoint.x,
1054
1145
  p1, // P[1].X, // bezierCurve.startControlPoint.x,
@@ -1062,7 +1153,6 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
1062
1153
  // var disc = b * b - 4 * a * c;
1063
1154
  var disc = polyX[1] * polyX[1] - 4 * polyX[0] * polyX[2];
1064
1155
 
1065
-
1066
1156
  // var polyX = CubicBezierCurve.utils.bezierCoeffs(p3,p2,p1,p0);
1067
1157
  // var a = polyX[0]; //polyX.a;
1068
1158
  // var b = polyX[1]; // .b;
@@ -1111,7 +1201,7 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
1111
1201
  * @param {number} tEnd – The end offset if the desired cub curve (must be in [0..1]).
1112
1202
  * @instance
1113
1203
  * @memberof CubicBezierCurve
1114
- * @return {CubicBezierCurve} The sub curve as a new curve.
1204
+ * @return {[Vertex, Vertex, Vertex, Vertex]} The sub curve as curve vertices.
1115
1205
  **/
1116
1206
  getSubCurvePointsAt: (curve: CubicBezierCurve, tStart: number, tEnd: number): [Vertex, Vertex, Vertex, Vertex] => {
1117
1207
  const startVec: Vector = new Vector(curve.getPointAt(tStart), curve.getTangentAt(tStart));
@@ -1196,8 +1286,8 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
1196
1286
  * @param {number} p3 - The end point coordinate.
1197
1287
  * @returns {[number,number,number,number]}
1198
1288
  */
1199
- bezierCoeffs: (p0: number, p1: number, p2: number, p3: number): [number,number,number,number] => {
1200
- const coeffs : [number,number,number,number] = [NaN,NaN,NaN,NaN]; //Array(4);
1289
+ bezierCoeffs: (p0: number, p1: number, p2: number, p3: number): [number, number, number, number] => {
1290
+ const coeffs: [number, number, number, number] = [NaN, NaN, NaN, NaN]; //Array(4);
1201
1291
  coeffs[0] = -p0 + 3 * p1 + -3 * p2 + p3;
1202
1292
  coeffs[1] = 3 * p0 - 6 * p1 + 3 * p2;
1203
1293
  coeffs[2] = -3 * p0 + 3 * p1;
@@ -1207,22 +1297,17 @@ export class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
1207
1297
 
1208
1298
  /**
1209
1299
  * Calculate the cubic polynomial coefficients used to find the bounding box.
1210
- *
1300
+ *
1211
1301
  * @param {number} p0 - The start point coordinate.
1212
1302
  * @param {number} p1 - The start control point coordinate.
1213
1303
  * @param {number} p2 - The end control point coordinate.
1214
1304
  * @param {number} p3 - The end point coordinate.
1215
1305
  * @returns {[number,number,number]}
1216
1306
  */
1217
- cubicPoly: (p0:number, p1:number, p2:number, p3:number) : [number,number,number] => {
1218
- return [
1219
- 3 * p3 - 9 * p2 + 9 * p1 - 3 * p0,
1220
- 6 * p0 - 12 * p1 + 6 * p2,
1221
- 3 * p1 - 3 * p0
1222
- ]
1307
+ cubicPoly: (p0: number, p1: number, p2: number, p3: number): [number, number, number] => {
1308
+ return [3 * p3 - 9 * p2 + 9 * p1 - 3 * p0, 6 * p0 - 12 * p1 + 6 * p2, 3 * p1 - 3 * p0];
1223
1309
  },
1224
1310
 
1225
-
1226
1311
  /**
1227
1312
  * sign of number, but is division safe: no zero returned :)
1228
1313
  */
package/src/ts/Line.ts CHANGED
@@ -18,7 +18,8 @@
18
18
  * @modified 2023-09-25 Changed param type of `intersection()` from Line to VertTuple.
19
19
  * @modified 2025-04-15 Class `Line` now implements interface `Intersectable`.
20
20
  * @modified 2025-04-16 Class `Line` now implements interface `IBounded`.
21
- * @version 2.4.0
21
+ * @modified 2026-08-16 Adding methods `Line.trimStart` and `Line.trimEnd`. Adding methods `Line.trimStartAt` and `Line.trimEndAt`.
22
+ * @version 2.5.0
22
23
  *
23
24
  * @file Line
24
25
  * @public
@@ -165,6 +166,88 @@ export class Line extends VertTuple<Line> implements IBounded, Intersectable, Pa
165
166
  }
166
167
  //--- END Implement PathSegment ---
167
168
 
169
+ /**
170
+ * Trim this line segment from the start point by the given amount.
171
+ * The amount must be positive and should be withing the segment's length. If the amount exceeds the segment's length
172
+ * then the length of the resulting line will be zero (0.0).
173
+ *
174
+ * @method trimStart
175
+ * @memberof Line
176
+ * @param {number} amount - The positive amount to trim the line from the start point `a`.
177
+ * @returns {Line} This for chaining, with updated point `a`.
178
+ */
179
+ trimStart(amount: number) {
180
+ // Calculate the relative position `t` on this line.
181
+ var t: number = amount / this.length();
182
+ // `t` should be inside 0..1 – otherwise the amount was too large or negative.
183
+ if (t < 0.0) {
184
+ return this;
185
+ }
186
+ if (t > 1.0) {
187
+ // Set the line to length zero (endpoint only)
188
+ this.a = this.b.clone();
189
+ return this;
190
+ }
191
+ this.a = this.vertAt(t);
192
+ return this;
193
+ }
194
+
195
+ /**
196
+ * Trim this line segment from the start point by the given relative amount.
197
+ * The amount must be positive and should be within 0.0 and 1.0. If the amount exceeds the segment's length
198
+ * then the length of the resulting line will be zero (0.0).
199
+ *
200
+ * @method trimStartAt
201
+ * @memberof Line
202
+ * @param {number} amount - The positive amount to trim the line from the start point `a`.
203
+ * @returns {Line} This for chaining, with updated point `a`.
204
+ */
205
+ trimStartAt(relativeAmount: number) {
206
+ // Calculate the relative position `t` on this line.
207
+ return this.trimStart(relativeAmount * this.length());
208
+ }
209
+
210
+ /**
211
+ * Trim this line segment from the end point by the given amount.
212
+ * The amount must be positive and should be withing the segment's length. If the amount exceeds the segment's length
213
+ * then the length of the resulting line will be zero (0.0).
214
+ *
215
+ * @method trimEnd
216
+ * @memberof Line
217
+ * @param {number} amount - The positive amount to trim the line from the end point `b`.
218
+ * @returns {Line} This for chaining, with updated point `b`.
219
+ */
220
+ trimEnd(amount: number) {
221
+ // Calculate the relative position `t` on this line.
222
+ var t: number = 1.0 - amount / this.length();
223
+ // `t` should be inside 0..1 – otherwise the amount was too large or negative.
224
+ if (t < 0.0) {
225
+ return this;
226
+ }
227
+ if (t > 1.0) {
228
+ // Set the line to length zero (endpoint only)
229
+ this.b = this.a.clone();
230
+ return this;
231
+ }
232
+ this.b = this.vertAt(t);
233
+ return this;
234
+ }
235
+
236
+ /**
237
+ * Trim this line segment from the end point by the given relative amount.
238
+ * The amount must be positive and should be within 0.0 and 1.0. If the amount exceeds the segment's length
239
+ * then the length of the resulting line will be zero (0.0).
240
+ *
241
+ * @method trimEndAt
242
+ * @memberof Line
243
+ * @param {number} amount - The positive amount to trim the line from the start point `a`.
244
+ * @returns {Line} This for chaining, with updated point `a`.
245
+ */
246
+ trimEndAt(relativeAmount: number) {
247
+ // Calculate the relative position `t` on this line.
248
+ return this.trimEnd(relativeAmount * this.length());
249
+ }
250
+
168
251
  //--- BEGIN --- Implement interface `Intersectable`
169
252
  /**
170
253
  * Get all line intersections with this polygon.