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.
- package/dist/index.esm.js +135 -36
- 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 +96 -17
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +2 -1
- package/src/cjs/PlotBoilerplate.d.ts +11 -1
- package/src/cjs/PlotBoilerplate.js +23 -7
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/VertexListeners.d.ts +2 -1
- package/src/cjs/VertexListeners.js +5 -1
- package/src/cjs/VertexListeners.js.map +1 -1
- package/src/cjs/draw.d.ts +18 -2
- package/src/cjs/draw.js +21 -2
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.d.ts +18 -3
- package/src/cjs/drawgl.js +19 -2
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +19 -1
- package/src/cjs/drawutilssvg.js +28 -5
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +18 -1
- package/src/cjs/interfaces/DrawLib.js +2 -0
- package/src/cjs/interfaces/DrawLib.js.map +1 -1
- package/src/cjs/utils/Params.d.ts +3 -2
- package/src/cjs/utils/Params.js +11 -3
- package/src/cjs/utils/Params.js.map +1 -1
- package/src/cjs/utils/WebColors.d.ts +2 -1
- package/src/cjs/utils/WebColors.js +15 -2
- package/src/cjs/utils/WebColors.js.map +1 -1
- package/src/cjs/utils/algorithms/HobbyPath.js +13 -16
- package/src/cjs/utils/algorithms/HobbyPath.js.map +1 -1
- package/src/cjs/utils/helpers/BezierResizeHelper.d.ts +144 -0
- package/src/cjs/utils/helpers/BezierResizeHelper.js +319 -0
- package/src/cjs/utils/helpers/BezierResizeHelper.js.map +1 -0
- package/src/esm/PlotBoilerplate.d.ts +11 -1
- package/src/esm/PlotBoilerplate.js +23 -7
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/VertexListeners.d.ts +2 -1
- package/src/esm/VertexListeners.js +5 -1
- package/src/esm/VertexListeners.js.map +1 -1
- package/src/esm/draw.d.ts +18 -2
- package/src/esm/draw.js +21 -2
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.d.ts +18 -3
- package/src/esm/drawgl.js +19 -2
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +19 -1
- package/src/esm/drawutilssvg.js +28 -5
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +18 -1
- package/src/esm/interfaces/DrawLib.js +2 -0
- package/src/esm/interfaces/DrawLib.js.map +1 -1
- package/src/esm/utils/Params.d.ts +3 -2
- package/src/esm/utils/Params.js +11 -3
- package/src/esm/utils/Params.js.map +1 -1
- package/src/esm/utils/WebColors.d.ts +2 -1
- package/src/esm/utils/WebColors.js +15 -2
- package/src/esm/utils/WebColors.js.map +1 -1
- package/src/esm/utils/algorithms/HobbyPath.js +13 -16
- package/src/esm/utils/algorithms/HobbyPath.js.map +1 -1
- package/src/esm/utils/helpers/BezierResizeHelper.d.ts +144 -0
- package/src/esm/utils/helpers/BezierResizeHelper.js +314 -0
- package/src/esm/utils/helpers/BezierResizeHelper.js.map +1 -0
- package/src/ts/PlotBoilerplate.ts +37 -11
- package/src/ts/VertexListeners.ts +5 -1
- package/src/ts/draw.ts +32 -2
- package/src/ts/drawgl.ts +38 -3
- package/src/ts/drawutilssvg.ts +33 -6
- package/src/ts/interfaces/DrawLib.ts +19 -1
- package/src/ts/utils/Params.ts +11 -3
- package/src/ts/utils/WebColors.ts +15 -2
- package/src/ts/utils/algorithms/HobbyPath.ts +248 -272
- package/src/ts/utils/helpers/BezierResizeHelper.ts +390 -0
- package/src/cjs/utils/_gup.js_ +0 -13
package/dist/index.esm.js
CHANGED
|
@@ -74,7 +74,8 @@ UIDGenerator.current = 0;
|
|
|
74
74
|
* @modified 2020-02-22 Added 'return this' to the add* functions (for chanining).
|
|
75
75
|
* @modified 2020-03-23 Ported to Typescript from JS.
|
|
76
76
|
* @modified 2020-11-17 Added the `click` handler.
|
|
77
|
-
* @
|
|
77
|
+
* @modified 2026-04-04 Adding null-listeners will now throw an error.
|
|
78
|
+
* @version 1.2.0
|
|
78
79
|
*
|
|
79
80
|
* @file VertexListeners
|
|
80
81
|
* @public
|
|
@@ -309,6 +310,9 @@ class VertexListeners {
|
|
|
309
310
|
* @private
|
|
310
311
|
*/
|
|
311
312
|
static _addListener(listeners, newListener) {
|
|
313
|
+
if (!newListener) {
|
|
314
|
+
throw new Error("Cannot add null listener. This would lead to unpredictable errors during event handling.");
|
|
315
|
+
}
|
|
312
316
|
for (var i in listeners) {
|
|
313
317
|
if (listeners[i] == newListener)
|
|
314
318
|
return false;
|
|
@@ -6447,6 +6451,9 @@ CircleSector.circleSectorUtils = {
|
|
|
6447
6451
|
* @modified 2026-01-04 Adding `lineJoin` attribute to the methods' `StrokeOptions` param.
|
|
6448
6452
|
* @modified 2026-01-04 Fixing missing `strokeOptions` param in the `drawutilssvg.polygon` method.
|
|
6449
6453
|
* @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
|
|
6454
|
+
* @modified 2026-04-04 Added the method `bounds`.
|
|
6455
|
+
* @modified 2026-04-04 Handling the `stroke-linecap` option now from the `StrokeOptions` interface.
|
|
6456
|
+
* @modified 2026-04-04 Chaning the `copyPathData` method by usind `Array.slice()`.
|
|
6450
6457
|
* @version 1.7.0
|
|
6451
6458
|
**/
|
|
6452
6459
|
const RAD_TO_DEG$1 = 180 / Math.PI;
|
|
@@ -6865,6 +6872,10 @@ class drawutilssvg {
|
|
|
6865
6872
|
if (strokeOptions && strokeOptions.lineJoin && drawutilssvg.nodeSupportsLineJoin(node.tagName)) {
|
|
6866
6873
|
node.setAttribute("stroke-linejoin", strokeOptions.lineJoin);
|
|
6867
6874
|
}
|
|
6875
|
+
// Set lineCap option?
|
|
6876
|
+
if (strokeOptions && strokeOptions.lineCap && drawutilssvg.nodeSupportsLineCap(node.tagName)) {
|
|
6877
|
+
node.setAttribute("stroke-linecap", strokeOptions.lineCap);
|
|
6878
|
+
}
|
|
6868
6879
|
}
|
|
6869
6880
|
_x(x) {
|
|
6870
6881
|
return this.offset.x + this.scale.x * x;
|
|
@@ -7335,6 +7346,22 @@ class drawutilssvg {
|
|
|
7335
7346
|
node.setAttribute("height", `${height * this.scale.y}`);
|
|
7336
7347
|
return this._bindFillDraw(node, "rect", color, lineWidth || 1);
|
|
7337
7348
|
}
|
|
7349
|
+
/**
|
|
7350
|
+
* Draw a rectangle at the given bounds; and with the specified line width and (CSS-) color.<br>
|
|
7351
|
+
*
|
|
7352
|
+
* @method bounds
|
|
7353
|
+
* @param {IBounds} bounds - The bounds rectangle to be drawn.
|
|
7354
|
+
* @param {string} color - The CSS color to draw the rectangle with.
|
|
7355
|
+
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
7356
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
7357
|
+
*
|
|
7358
|
+
* @return {R}
|
|
7359
|
+
* @instance
|
|
7360
|
+
* @memberof DrawLib
|
|
7361
|
+
*/
|
|
7362
|
+
bounds(bounds, color, lineWidth, strokeOptions) {
|
|
7363
|
+
this.rect(bounds.min, bounds.max.x - bounds.min.x, bounds.max.y - bounds.min.y, color, lineWidth, strokeOptions);
|
|
7364
|
+
}
|
|
7338
7365
|
/**
|
|
7339
7366
|
* Draw a grid of horizontal and vertical lines with the given (CSS-) color.
|
|
7340
7367
|
*
|
|
@@ -7788,11 +7815,8 @@ class drawutilssvg {
|
|
|
7788
7815
|
* @memberof drawutilssvg
|
|
7789
7816
|
*/
|
|
7790
7817
|
static copyPathData(data) {
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
copy[i] = data[i];
|
|
7794
|
-
}
|
|
7795
|
-
return copy;
|
|
7818
|
+
// To create a shallow copy we can just use the `slice` method.
|
|
7819
|
+
return data.slice();
|
|
7796
7820
|
}
|
|
7797
7821
|
/**
|
|
7798
7822
|
* Transform the given path data (translate and scale. rotating is not intended here).
|
|
@@ -7963,6 +7987,9 @@ class drawutilssvg {
|
|
|
7963
7987
|
static nodeSupportsLineJoin(nodeName) {
|
|
7964
7988
|
return ["line", "path", "circle", "ellipse", "rectangle", "rect"].includes(nodeName);
|
|
7965
7989
|
}
|
|
7990
|
+
static nodeSupportsLineCap(nodeName) {
|
|
7991
|
+
return ["line", "path", "circle", "ellipse", "rectangle", "rect"].includes(nodeName);
|
|
7992
|
+
}
|
|
7966
7993
|
/**
|
|
7967
7994
|
* Creates a basic <line> node with start and end coordinates. The created node will not
|
|
7968
7995
|
* be bound to any root node.
|
|
@@ -8149,7 +8176,9 @@ drawutilssvg.HEAD_XML = [
|
|
|
8149
8176
|
* @modified 2024-09-13 Remoed the scaling of `lineWidth` in the `polygon` and `polyline` methods. This makes no sense here and doesn't match up with the behavior of other line functions.
|
|
8150
8177
|
* @modified 2026-01-04 Adding `lineJoin` attribute to the `StrokeOptions`.
|
|
8151
8178
|
* @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
|
|
8152
|
-
* @
|
|
8179
|
+
* @modified 2026-04-04 Added the method `bounds`.
|
|
8180
|
+
* @modified 2026-04-04 Handling the `lineCap` attribute in the `StrokeOptions`.
|
|
8181
|
+
* @version 1.15.0
|
|
8153
8182
|
**/
|
|
8154
8183
|
// Todo: rename this class to Drawutils?
|
|
8155
8184
|
/**
|
|
@@ -8182,7 +8211,7 @@ class drawutils {
|
|
|
8182
8211
|
* @param {StrokeOptions=} strokeOptions -
|
|
8183
8212
|
*/
|
|
8184
8213
|
applyStrokeOpts(strokeOptions) {
|
|
8185
|
-
var _a, _b, _c;
|
|
8214
|
+
var _a, _b, _c, _d;
|
|
8186
8215
|
this.ctx.setLineDash(((_a = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.dashArray) !== null && _a !== void 0 ? _a : []).map((dashArrayElem) => {
|
|
8187
8216
|
// Note assume scale.x === scale.y
|
|
8188
8217
|
// Invariant scale makes funny stuff anyway.
|
|
@@ -8190,6 +8219,7 @@ class drawutils {
|
|
|
8190
8219
|
}));
|
|
8191
8220
|
this.ctx.lineDashOffset = ((_b = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.dashOffset) !== null && _b !== void 0 ? _b : 0) * this.scale.x;
|
|
8192
8221
|
this.ctx.lineJoin = (_c = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.lineJoin) !== null && _c !== void 0 ? _c : null;
|
|
8222
|
+
this.ctx.lineCap = (_d = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.lineCap) !== null && _d !== void 0 ? _d : null;
|
|
8193
8223
|
}
|
|
8194
8224
|
// +---------------------------------------------------------------------------------
|
|
8195
8225
|
// | This is the final helper function for drawing and filling stuff. It is not
|
|
@@ -8560,6 +8590,22 @@ class drawutils {
|
|
|
8560
8590
|
this._fillOrDraw(color);
|
|
8561
8591
|
this.ctx.restore();
|
|
8562
8592
|
}
|
|
8593
|
+
/**
|
|
8594
|
+
* Draw a rectangle at the given bounds; and with the specified line width and (CSS-) color.<br>
|
|
8595
|
+
*
|
|
8596
|
+
* @method bounds
|
|
8597
|
+
* @param {IBounds} bounds - The bounds rectangle to be drawn.
|
|
8598
|
+
* @param {string} color - The CSS color to draw the rectangle with.
|
|
8599
|
+
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
8600
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
8601
|
+
*
|
|
8602
|
+
* @return {R}
|
|
8603
|
+
* @instance
|
|
8604
|
+
* @memberof DrawLib
|
|
8605
|
+
*/
|
|
8606
|
+
bounds(bounds, color, lineWidth, strokeOptions) {
|
|
8607
|
+
this.rect(bounds.min, bounds.max.x - bounds.min.x, bounds.max.y - bounds.min.y, color, lineWidth, strokeOptions);
|
|
8608
|
+
}
|
|
8563
8609
|
/**
|
|
8564
8610
|
* Draw the given (cubic) bézier curve.
|
|
8565
8611
|
*
|
|
@@ -9258,7 +9304,8 @@ drawutils.helpers = {
|
|
|
9258
9304
|
* @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
|
|
9259
9305
|
* @modified 2023-09-29 Added the `lineDashes` attribute.
|
|
9260
9306
|
* @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
|
|
9261
|
-
* @
|
|
9307
|
+
* @modified 2026-04-04 Added the method `bounds`.
|
|
9308
|
+
* @version 0.0.11
|
|
9262
9309
|
**/
|
|
9263
9310
|
/**
|
|
9264
9311
|
* @classdesc A wrapper class for basic drawing operations. This is the WebGL
|
|
@@ -9703,9 +9750,25 @@ class drawutilsgl {
|
|
|
9703
9750
|
* @param {string} color - The color to use.
|
|
9704
9751
|
* @param {number=1} lineWidth - (optional) The line with to use (default is 1).
|
|
9705
9752
|
**/
|
|
9706
|
-
rect(position, width, height, color, lineWidth) {
|
|
9753
|
+
rect(position, width, height, color, lineWidth, strokeOptions) {
|
|
9707
9754
|
// NOT YET IMPLEMENTED
|
|
9708
9755
|
}
|
|
9756
|
+
/**
|
|
9757
|
+
* Draw a rectangle at the given bounds; and with the specified line width and (CSS-) color.<br>
|
|
9758
|
+
*
|
|
9759
|
+
* @method bounds
|
|
9760
|
+
* @param {IBounds} bounds - The bounds rectangle to be drawn.
|
|
9761
|
+
* @param {string} color - The CSS color to draw the rectangle with.
|
|
9762
|
+
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
9763
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
9764
|
+
*
|
|
9765
|
+
* @return {R}
|
|
9766
|
+
* @instance
|
|
9767
|
+
* @memberof DrawLib
|
|
9768
|
+
*/
|
|
9769
|
+
bounds(bounds, color, lineWidth, strokeOptions) {
|
|
9770
|
+
this.rect(bounds.min, bounds.max.x - bounds.min.x, bounds.max.y - bounds.min.y, color, lineWidth, strokeOptions);
|
|
9771
|
+
}
|
|
9709
9772
|
/**
|
|
9710
9773
|
* Draw a grid of horizontal and vertical lines with the given (CSS-) color.
|
|
9711
9774
|
*
|
|
@@ -12517,8 +12580,9 @@ VEllipseSector.ellipseSectorUtils = {
|
|
|
12517
12580
|
* @modified 2025-05-07 Moving full vectors now by default when vector point a is moved.
|
|
12518
12581
|
* @modified 2025-05-20 Applying `lineWith` parameter in the draw routine for vectors (had been missing).
|
|
12519
12582
|
* @modified 2026-03-13 Changed visibility of `setZoom` and `setOffset` to public. There was no good reason to have the private.
|
|
12583
|
+
* @modified 2026-04-04 Added `isInPanningMode` attribute and `isPanning` method.
|
|
12520
12584
|
*
|
|
12521
|
-
* @version 1.
|
|
12585
|
+
* @version 1.22.0
|
|
12522
12586
|
*
|
|
12523
12587
|
* @file PlotBoilerplate
|
|
12524
12588
|
* @fileoverview The main class.
|
|
@@ -12955,6 +13019,9 @@ class PlotBoilerplate {
|
|
|
12955
13019
|
this.resizeCanvas();
|
|
12956
13020
|
this.updateCSSscale();
|
|
12957
13021
|
}
|
|
13022
|
+
isPanning() {
|
|
13023
|
+
return this.isInPanningMode;
|
|
13024
|
+
}
|
|
12958
13025
|
/**
|
|
12959
13026
|
* Set the current zoom and draw offset to fit the given bounds.
|
|
12960
13027
|
*
|
|
@@ -13834,13 +13901,12 @@ class PlotBoilerplate {
|
|
|
13834
13901
|
**/
|
|
13835
13902
|
// TODO: this was moved to the DOM utils
|
|
13836
13903
|
getAvailableContainerSpace() {
|
|
13837
|
-
const
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
var padding = this.getFProp(container, "padding") || 0, border = this.getFProp(_self.canvas, "border-width") || 0, pl = this.getFProp(container, "padding-left") || padding, pr = this.getFProp(container, "padding-right") || padding, pt = this.getFProp(container, "padding-top") || padding, pb = this.getFProp(container, "padding-bottom") || padding, bl = this.getFProp(_self.canvas, "border-left-width") || border, br = this.getFProp(_self.canvas, "border-right-width") || border, bt = this.getFProp(_self.canvas, "border-top-width") || border, bb = this.getFProp(_self.canvas, "border-bottom-width") || border;
|
|
13904
|
+
const container = this.canvas.parentNode; // Element | Document | DocumentFragment;
|
|
13905
|
+
this.canvas.style.display = "none";
|
|
13906
|
+
var padding = this.getFProp(container, "padding") || 0, border = this.getFProp(this.canvas, "border-width") || 0, pl = this.getFProp(container, "padding-left") || padding, pr = this.getFProp(container, "padding-right") || padding, pt = this.getFProp(container, "padding-top") || padding, pb = this.getFProp(container, "padding-bottom") || padding, bl = this.getFProp(this.canvas, "border-left-width") || border, br = this.getFProp(this.canvas, "border-right-width") || border, bt = this.getFProp(this.canvas, "border-top-width") || border, bb = this.getFProp(this.canvas, "border-bottom-width") || border;
|
|
13841
13907
|
var w = container.clientWidth;
|
|
13842
13908
|
var h = container.clientHeight;
|
|
13843
|
-
|
|
13909
|
+
this.canvas.style.display = "block";
|
|
13844
13910
|
return { width: w - pl - pr - bl - br, height: h - pt - pb - bt - bb };
|
|
13845
13911
|
}
|
|
13846
13912
|
/**
|
|
@@ -14102,7 +14168,8 @@ class PlotBoilerplate {
|
|
|
14102
14168
|
// not this one. So this tab will never receive any [Ctrl-down] events
|
|
14103
14169
|
// until next keypress; the implication is, that [Ctrl] would still
|
|
14104
14170
|
// considered to be pressed which is not true.
|
|
14105
|
-
if (this.keyHandler && (this.keyHandler.isDown("alt") || this.keyHandler.isDown("spacebar"))) {
|
|
14171
|
+
// if (this.keyHandler && (this.keyHandler.isDown("alt") || this.keyHandler.isDown("spacebar"))) {
|
|
14172
|
+
if (this.isInPanningMode) {
|
|
14106
14173
|
if (!this.config.enablePan) {
|
|
14107
14174
|
return;
|
|
14108
14175
|
}
|
|
@@ -14453,6 +14520,18 @@ class PlotBoilerplate {
|
|
|
14453
14520
|
_self.selectVerticesInPolygon(_self.selectPolygon);
|
|
14454
14521
|
_self.selectPolygon = null;
|
|
14455
14522
|
_self.redraw();
|
|
14523
|
+
})
|
|
14524
|
+
.down("alt", function () {
|
|
14525
|
+
_self.isInPanningMode = true;
|
|
14526
|
+
})
|
|
14527
|
+
.up("alt", function () {
|
|
14528
|
+
_self.isInPanningMode = false;
|
|
14529
|
+
})
|
|
14530
|
+
.down("spacebar", function () {
|
|
14531
|
+
_self.isInPanningMode = true;
|
|
14532
|
+
})
|
|
14533
|
+
.up("spacebar", function () {
|
|
14534
|
+
_self.isInPanningMode = false;
|
|
14456
14535
|
});
|
|
14457
14536
|
} // END IF enableKeys?
|
|
14458
14537
|
else {
|
|
@@ -15064,6 +15143,7 @@ const NGons = {
|
|
|
15064
15143
|
* @version 1.0.0
|
|
15065
15144
|
* @date 2023-03-13
|
|
15066
15145
|
* @modified 2024-08-26 Added the `hasParam` method.
|
|
15146
|
+
* @modified 2026-05-22 Added the `isValueAllowed` function param to the getter methods.
|
|
15067
15147
|
*/
|
|
15068
15148
|
class Params {
|
|
15069
15149
|
constructor(baseParams) {
|
|
@@ -15072,19 +15152,26 @@ class Params {
|
|
|
15072
15152
|
hasParam(name) {
|
|
15073
15153
|
return this.baseParams.hasOwnProperty(name);
|
|
15074
15154
|
}
|
|
15075
|
-
getString(name, fallback) {
|
|
15155
|
+
getString(name, fallback, isValueAllowed) {
|
|
15076
15156
|
let value = this.baseParams[name];
|
|
15077
15157
|
if (typeof value === "undefined" || !value || (value = value.trim()).length === 0) {
|
|
15078
15158
|
return fallback;
|
|
15079
15159
|
}
|
|
15160
|
+
if (isValueAllowed && !isValueAllowed(value)) {
|
|
15161
|
+
return fallback;
|
|
15162
|
+
}
|
|
15080
15163
|
return value;
|
|
15081
15164
|
}
|
|
15082
|
-
getNumber(name, fallback) {
|
|
15165
|
+
getNumber(name, fallback, isValueAllowed) {
|
|
15083
15166
|
let value = this.baseParams[name];
|
|
15084
15167
|
if (typeof value === "undefined" || !value || (value = value.trim()).length === 0) {
|
|
15085
15168
|
return fallback;
|
|
15086
15169
|
}
|
|
15087
|
-
|
|
15170
|
+
var numericValue = Number(value);
|
|
15171
|
+
if (isValueAllowed && !isValueAllowed(numericValue)) {
|
|
15172
|
+
return fallback;
|
|
15173
|
+
}
|
|
15174
|
+
return numericValue;
|
|
15088
15175
|
}
|
|
15089
15176
|
getBoolean(name, fallback) {
|
|
15090
15177
|
let value = this.baseParams[name];
|
|
@@ -16559,7 +16646,8 @@ Color.CSS_COLORS = {
|
|
|
16559
16646
|
* @modified 2020-10-23 Ported to Typescript.
|
|
16560
16647
|
* @modified 2020-10-30 Exporting each color under its name globally.
|
|
16561
16648
|
* @modified 2025-12-08 Replaying self defined colors by official web colors.
|
|
16562
|
-
* @
|
|
16649
|
+
* @modified 2026-03-18 Fixing global `WebColors` array.
|
|
16650
|
+
* @version 1.0.3
|
|
16563
16651
|
**/
|
|
16564
16652
|
const Red = Color.Red; // Color.makeRGB(255,67,55);
|
|
16565
16653
|
const Pink = Color.Pink; // Color.makeRGB(232,31,100);
|
|
@@ -16581,7 +16669,19 @@ const LightGreen = Color.LightGreen; // Color.makeRGB(141,195,67);
|
|
|
16581
16669
|
* @requires Color
|
|
16582
16670
|
*
|
|
16583
16671
|
*/
|
|
16584
|
-
const WebColors = [
|
|
16672
|
+
const WebColors = [
|
|
16673
|
+
Color.Red,
|
|
16674
|
+
Color.Pink,
|
|
16675
|
+
Color.Purple,
|
|
16676
|
+
Color.DeepPink,
|
|
16677
|
+
Color.Indigo,
|
|
16678
|
+
Color.Blue,
|
|
16679
|
+
Color.LightBlue,
|
|
16680
|
+
Color.Cyan,
|
|
16681
|
+
Color.Teal,
|
|
16682
|
+
Color.Green,
|
|
16683
|
+
Color.LightGreen
|
|
16684
|
+
];
|
|
16585
16685
|
/**
|
|
16586
16686
|
* A helper function to shuffle the colors into a new order.
|
|
16587
16687
|
*/
|
|
@@ -18221,7 +18321,6 @@ class HobbyPath {
|
|
|
18221
18321
|
constructor(vertices) {
|
|
18222
18322
|
this.vertices = vertices ? vertices : [];
|
|
18223
18323
|
}
|
|
18224
|
-
;
|
|
18225
18324
|
/**
|
|
18226
18325
|
* Add a new point to the end of the vertex sequence.
|
|
18227
18326
|
*
|
|
@@ -18233,7 +18332,6 @@ class HobbyPath {
|
|
|
18233
18332
|
addPoint(p) {
|
|
18234
18333
|
this.vertices.push(p);
|
|
18235
18334
|
}
|
|
18236
|
-
;
|
|
18237
18335
|
/**
|
|
18238
18336
|
* Generate a sequence of cubic Bézier curves from the point set.
|
|
18239
18337
|
*
|
|
@@ -18266,7 +18364,6 @@ class HobbyPath {
|
|
|
18266
18364
|
return [];
|
|
18267
18365
|
}
|
|
18268
18366
|
}
|
|
18269
|
-
;
|
|
18270
18367
|
/**
|
|
18271
18368
|
* Computes the control point coordinates for a Hobby curve through
|
|
18272
18369
|
* the points given.
|
|
@@ -18280,13 +18377,17 @@ class HobbyPath {
|
|
|
18280
18377
|
**/
|
|
18281
18378
|
hobbyControls(circular, omega) {
|
|
18282
18379
|
// This is a version that works for both, closed and non-closed paths.
|
|
18283
|
-
if (typeof omega ===
|
|
18380
|
+
if (typeof omega === "undefined")
|
|
18284
18381
|
omega = 0;
|
|
18285
18382
|
let n = this.vertices.length - (circular ? 0 : 1);
|
|
18286
18383
|
let D = new Array(n);
|
|
18287
18384
|
let ds = new Array(n);
|
|
18288
|
-
var succ = (i) => {
|
|
18289
|
-
|
|
18385
|
+
var succ = (i) => {
|
|
18386
|
+
return circular ? (i + 1) % n : i + 1;
|
|
18387
|
+
};
|
|
18388
|
+
var pred = (i) => {
|
|
18389
|
+
return circular ? (i + n - 1) % n : i - 1;
|
|
18390
|
+
};
|
|
18290
18391
|
for (let i = 0; i < n; i++) {
|
|
18291
18392
|
// the "next" point in a modular way
|
|
18292
18393
|
let j = succ(i);
|
|
@@ -18294,7 +18395,7 @@ class HobbyPath {
|
|
|
18294
18395
|
D[i] = Math.sqrt(ds[i].x * ds[i].x + ds[i].y * ds[i].y);
|
|
18295
18396
|
}
|
|
18296
18397
|
let gamma = new Array(n + (circular ? 0 : 1));
|
|
18297
|
-
for (let i =
|
|
18398
|
+
for (let i = circular ? 0 : 1; i < n; i++) {
|
|
18298
18399
|
// the "previous" point in a modular way
|
|
18299
18400
|
let k = pred(i);
|
|
18300
18401
|
let sin = ds[k].y / D[k];
|
|
@@ -18308,7 +18409,7 @@ class HobbyPath {
|
|
|
18308
18409
|
let b = new Array(n + (circular ? 0 : 1));
|
|
18309
18410
|
let c = new Array(n + (circular ? 0 : 1));
|
|
18310
18411
|
let d = new Array(n + (circular ? 0 : 1));
|
|
18311
|
-
for (let i =
|
|
18412
|
+
for (let i = circular ? 0 : 1; i < n; i++) {
|
|
18312
18413
|
// j is the "next" point, k the "previous" one
|
|
18313
18414
|
let j = succ(i);
|
|
18314
18415
|
let k = pred(i);
|
|
@@ -18358,18 +18459,16 @@ class HobbyPath {
|
|
|
18358
18459
|
let endControlPoints = new Array(n);
|
|
18359
18460
|
for (let i = 0; i < n; i++) {
|
|
18360
18461
|
let j = succ(i);
|
|
18361
|
-
let a = HobbyPath.utils.rho(alpha[i], beta[i]) * D[i] / 3;
|
|
18362
|
-
let b = HobbyPath.utils.rho(beta[i], alpha[i]) * D[i] / 3;
|
|
18462
|
+
let a = (HobbyPath.utils.rho(alpha[i], beta[i]) * D[i]) / 3;
|
|
18463
|
+
let b = (HobbyPath.utils.rho(beta[i], alpha[i]) * D[i]) / 3;
|
|
18363
18464
|
let v = HobbyPath.utils.normalize(HobbyPath.utils.rotateAngle(ds[i], alpha[i]));
|
|
18364
18465
|
startControlPoints[i] = new Vertex$1(this.vertices[i].x + a * v.x, this.vertices[i].y + a * v.y);
|
|
18365
18466
|
v = HobbyPath.utils.normalize(HobbyPath.utils.rotateAngle(ds[i], -beta[i]));
|
|
18366
18467
|
endControlPoints[i] = new Vertex$1(this.vertices[j].x - b * v.x, this.vertices[j].y - b * v.y);
|
|
18367
18468
|
}
|
|
18368
|
-
return { startControlPoints: startControlPoints,
|
|
18369
|
-
endControlPoints: endControlPoints
|
|
18370
|
-
};
|
|
18469
|
+
return { startControlPoints: startControlPoints, endControlPoints: endControlPoints };
|
|
18371
18470
|
}
|
|
18372
|
-
}
|
|
18471
|
+
} // END class
|
|
18373
18472
|
HobbyPath.utils = {
|
|
18374
18473
|
// rotates a vector [x, y] about an angle; the angle is implicitly
|
|
18375
18474
|
// determined by its sine and cosine
|