plotboilerplate 1.27.1 → 1.28.1

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.
Files changed (78) hide show
  1. package/dist/index.esm.js +135 -36
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.esm.min.js +1 -1
  4. package/dist/index.esm.min.js.map +1 -1
  5. package/dist/plotboilerplate.browser.min.js +1 -1
  6. package/dist/plotboilerplate.browser.min.js.map +1 -1
  7. package/dist/plotboilerplate.js +96 -17
  8. package/dist/plotboilerplate.min.js +1 -1
  9. package/package.json +2 -1
  10. package/src/cjs/PlotBoilerplate.d.ts +11 -1
  11. package/src/cjs/PlotBoilerplate.js +23 -7
  12. package/src/cjs/PlotBoilerplate.js.map +1 -1
  13. package/src/cjs/VertexListeners.d.ts +2 -1
  14. package/src/cjs/VertexListeners.js +5 -1
  15. package/src/cjs/VertexListeners.js.map +1 -1
  16. package/src/cjs/draw.d.ts +18 -2
  17. package/src/cjs/draw.js +21 -2
  18. package/src/cjs/draw.js.map +1 -1
  19. package/src/cjs/drawgl.d.ts +18 -3
  20. package/src/cjs/drawgl.js +19 -2
  21. package/src/cjs/drawgl.js.map +1 -1
  22. package/src/cjs/drawutilssvg.d.ts +19 -1
  23. package/src/cjs/drawutilssvg.js +28 -5
  24. package/src/cjs/drawutilssvg.js.map +1 -1
  25. package/src/cjs/interfaces/DrawLib.d.ts +18 -1
  26. package/src/cjs/interfaces/DrawLib.js +2 -0
  27. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  28. package/src/cjs/utils/Params.d.ts +3 -2
  29. package/src/cjs/utils/Params.js +11 -3
  30. package/src/cjs/utils/Params.js.map +1 -1
  31. package/src/cjs/utils/WebColors.d.ts +2 -1
  32. package/src/cjs/utils/WebColors.js +15 -2
  33. package/src/cjs/utils/WebColors.js.map +1 -1
  34. package/src/cjs/utils/algorithms/HobbyPath.js +13 -16
  35. package/src/cjs/utils/algorithms/HobbyPath.js.map +1 -1
  36. package/src/cjs/utils/helpers/BezierResizeHelper.d.ts +144 -0
  37. package/src/cjs/utils/helpers/BezierResizeHelper.js +319 -0
  38. package/src/cjs/utils/helpers/BezierResizeHelper.js.map +1 -0
  39. package/src/esm/PlotBoilerplate.d.ts +11 -1
  40. package/src/esm/PlotBoilerplate.js +23 -7
  41. package/src/esm/PlotBoilerplate.js.map +1 -1
  42. package/src/esm/VertexListeners.d.ts +2 -1
  43. package/src/esm/VertexListeners.js +5 -1
  44. package/src/esm/VertexListeners.js.map +1 -1
  45. package/src/esm/draw.d.ts +18 -2
  46. package/src/esm/draw.js +21 -2
  47. package/src/esm/draw.js.map +1 -1
  48. package/src/esm/drawgl.d.ts +18 -3
  49. package/src/esm/drawgl.js +19 -2
  50. package/src/esm/drawgl.js.map +1 -1
  51. package/src/esm/drawutilssvg.d.ts +19 -1
  52. package/src/esm/drawutilssvg.js +28 -5
  53. package/src/esm/drawutilssvg.js.map +1 -1
  54. package/src/esm/interfaces/DrawLib.d.ts +18 -1
  55. package/src/esm/interfaces/DrawLib.js +2 -0
  56. package/src/esm/interfaces/DrawLib.js.map +1 -1
  57. package/src/esm/utils/Params.d.ts +3 -2
  58. package/src/esm/utils/Params.js +11 -3
  59. package/src/esm/utils/Params.js.map +1 -1
  60. package/src/esm/utils/WebColors.d.ts +2 -1
  61. package/src/esm/utils/WebColors.js +15 -2
  62. package/src/esm/utils/WebColors.js.map +1 -1
  63. package/src/esm/utils/algorithms/HobbyPath.js +13 -16
  64. package/src/esm/utils/algorithms/HobbyPath.js.map +1 -1
  65. package/src/esm/utils/helpers/BezierResizeHelper.d.ts +144 -0
  66. package/src/esm/utils/helpers/BezierResizeHelper.js +314 -0
  67. package/src/esm/utils/helpers/BezierResizeHelper.js.map +1 -0
  68. package/src/ts/PlotBoilerplate.ts +37 -11
  69. package/src/ts/VertexListeners.ts +5 -1
  70. package/src/ts/draw.ts +32 -2
  71. package/src/ts/drawgl.ts +38 -3
  72. package/src/ts/drawutilssvg.ts +33 -6
  73. package/src/ts/interfaces/DrawLib.ts +19 -1
  74. package/src/ts/utils/Params.ts +11 -3
  75. package/src/ts/utils/WebColors.ts +15 -2
  76. package/src/ts/utils/algorithms/HobbyPath.ts +248 -272
  77. package/src/ts/utils/helpers/BezierResizeHelper.ts +390 -0
  78. package/src/cjs/utils/_gup.js_ +0 -13
@@ -26,12 +26,14 @@
26
26
  * @modified 2023-09-29 Added the `lineDashes` attribute.
27
27
  * @modified 2023-09-30 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
28
28
  * @modified 2026-01-04 Adding optional `lineJoin` attribute to the `StrokeOptions` interface.
29
+ * @modified 2026-04-04 Added the method `bounds`.
30
+ * @modified 2026-04-04 Added the `lineCap` attribute to the `StrokeOptions`.
29
31
  **/
30
32
 
31
33
  import { Bounds } from "../Bounds";
32
34
  import { Polygon } from "../Polygon";
33
35
  import { Vertex } from "../Vertex";
34
- import { SVGPathParams, UID, XYCoords } from "./core";
36
+ import { IBounds, SVGPathParams, UID, XYCoords } from "./core";
35
37
 
36
38
  export interface DrawLibConfiguration {
37
39
  // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation#types
@@ -71,6 +73,7 @@ export interface StrokeOptions {
71
73
  dashArray?: Array<number>;
72
74
  // SVG has more options for this: arcs | bevel | miter | miter-clip | round
73
75
  lineJoin?: "round" | "bevel" | "miter";
76
+ lineCap?: "butt" | "round" | "square";
74
77
  }
75
78
 
76
79
  /**
@@ -468,6 +471,21 @@ export interface DrawLib<R> {
468
471
  strokeOptions?: StrokeOptions
469
472
  ) => R;
470
473
 
474
+ /**
475
+ * Draw a rectangle at the given bounds; and with the specified line width and (CSS-) color.<br>
476
+ *
477
+ * @method bounds
478
+ * @param {IBounds} bounds - The bounds rectangle to be drawn.
479
+ * @param {string} color - The CSS color to draw the rectangle with.
480
+ * @param {number=} lineWidth - (optional) The line width to use; default is 1.
481
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
482
+ *
483
+ * @return {R}
484
+ * @instance
485
+ * @memberof DrawLib
486
+ */
487
+ bounds: (bounds: IBounds, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
488
+
471
489
  /**
472
490
  * Draw a grid of horizontal and vertical lines with the given (CSS-) color.
473
491
  *
@@ -6,6 +6,7 @@
6
6
  * @version 1.0.0
7
7
  * @date 2023-03-13
8
8
  * @modified 2024-08-26 Added the `hasParam` method.
9
+ * @modified 2026-05-22 Added the `isValueAllowed` function param to the getter methods.
9
10
  */
10
11
 
11
12
  export class Params {
@@ -19,20 +20,27 @@ export class Params {
19
20
  return this.baseParams.hasOwnProperty(name);
20
21
  }
21
22
 
22
- getString(name: string, fallback: string): string {
23
+ getString(name: string, fallback: string, isValueAllowed?: (value: string) => boolean): string {
23
24
  let value = this.baseParams[name];
24
25
  if (typeof value === "undefined" || !value || (value = value.trim()).length === 0) {
25
26
  return fallback;
26
27
  }
28
+ if (isValueAllowed && !isValueAllowed(value)) {
29
+ return fallback;
30
+ }
27
31
  return value;
28
32
  }
29
33
 
30
- getNumber(name: string, fallback: number): number {
34
+ getNumber(name: string, fallback: number, isValueAllowed?: (value: number) => boolean): number {
31
35
  let value = this.baseParams[name];
32
36
  if (typeof value === "undefined" || !value || (value = value.trim()).length === 0) {
33
37
  return fallback;
34
38
  }
35
- return Number(value);
39
+ var numericValue = Number(value);
40
+ if (isValueAllowed && !isValueAllowed(numericValue)) {
41
+ return fallback;
42
+ }
43
+ return numericValue;
36
44
  }
37
45
 
38
46
  getBoolean(name: string, fallback: boolean): boolean {
@@ -4,7 +4,8 @@
4
4
  * @modified 2020-10-23 Ported to Typescript.
5
5
  * @modified 2020-10-30 Exporting each color under its name globally.
6
6
  * @modified 2025-12-08 Replaying self defined colors by official web colors.
7
- * @version 1.0.2
7
+ * @modified 2026-03-18 Fixing global `WebColors` array.
8
+ * @version 1.0.3
8
9
  **/
9
10
 
10
11
  import { Color } from "./datastructures/Color";
@@ -30,7 +31,19 @@ export const LightGreen: Color = Color.LightGreen; // Color.makeRGB(141,195,67);
30
31
  * @requires Color
31
32
  *
32
33
  */
33
- export const WebColors: Array<Color> = [Red, Pink, Purple, DeepPurple, Indigo, Blue, LightBlue, Cyan, Teal, Green, LightGreen];
34
+ export const WebColors: Array<Color> = [
35
+ Color.Red,
36
+ Color.Pink,
37
+ Color.Purple,
38
+ Color.DeepPink,
39
+ Color.Indigo,
40
+ Color.Blue,
41
+ Color.LightBlue,
42
+ Color.Cyan,
43
+ Color.Teal,
44
+ Color.Green,
45
+ Color.LightGreen
46
+ ];
34
47
 
35
48
  /**
36
49
  * A helper function to shuffle the colors into a new order.