plotboilerplate 1.18.0 → 1.19.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 +166 -39
- 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 +164 -37
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/Bounds.d.ts +11 -1
- package/src/cjs/Bounds.js +13 -1
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/CubicBezierCurve.d.ts +20 -3
- package/src/cjs/CubicBezierCurve.js +25 -2
- package/src/cjs/CubicBezierCurve.js.map +1 -1
- package/src/cjs/Line.d.ts +46 -4
- package/src/cjs/Line.js +60 -3
- package/src/cjs/Line.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +4 -2
- package/src/cjs/PlotBoilerplate.js +44 -28
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Polygon.js +1 -1
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/Vector.d.ts +14 -3
- package/src/cjs/Vector.js +21 -2
- package/src/cjs/Vector.js.map +1 -1
- package/src/cjs/interfaces/additionals.d.ts +95 -0
- package/src/cjs/interfaces/additionals.js +3 -0
- package/src/cjs/interfaces/additionals.js.map +1 -0
- package/src/cjs/interfaces/core.d.ts +4 -0
- package/src/cjs/interfaces/core.js +1 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/interfaces/index.d.ts +1 -0
- package/src/cjs/interfaces/index.js +1 -0
- package/src/cjs/interfaces/index.js.map +1 -1
- package/src/cjs/utils/algorithms/arrayShuffle.d.ts +8 -0
- package/src/cjs/utils/algorithms/arrayShuffle.js +15 -0
- package/src/cjs/utils/algorithms/arrayShuffle.js.map +1 -0
- package/src/cjs/utils/algorithms/detectPaths.d.ts +20 -0
- package/src/cjs/utils/algorithms/detectPaths.js +169 -0
- package/src/cjs/utils/algorithms/detectPaths.js.map +1 -0
- package/src/cjs/utils/datastructures/GenericPath.d.ts +75 -0
- package/src/cjs/utils/datastructures/GenericPath.js +105 -0
- package/src/cjs/utils/datastructures/GenericPath.js.map +1 -0
- package/src/cjs/utils/datastructures/GirihTile.d.ts +1 -1
- package/src/esm/Bounds.d.ts +11 -1
- package/src/esm/Bounds.js +13 -1
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/CubicBezierCurve.d.ts +20 -3
- package/src/esm/CubicBezierCurve.js +25 -2
- package/src/esm/CubicBezierCurve.js.map +1 -1
- package/src/esm/Line.d.ts +46 -4
- package/src/esm/Line.js +60 -3
- package/src/esm/Line.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +4 -2
- package/src/esm/PlotBoilerplate.js +44 -28
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Polygon.js +1 -1
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/Vector.d.ts +13 -2
- package/src/esm/Vector.js +23 -4
- package/src/esm/Vector.js.map +1 -1
- package/src/esm/interfaces/additionals.d.ts +95 -0
- package/src/esm/interfaces/additionals.js +2 -0
- package/src/esm/interfaces/additionals.js.map +1 -0
- package/src/esm/interfaces/core.d.ts +4 -0
- package/src/esm/interfaces/core.js +1 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/interfaces/index.d.ts +1 -0
- package/src/esm/interfaces/index.js +1 -0
- package/src/esm/interfaces/index.js.map +1 -1
- package/src/esm/utils/algorithms/arrayShuffle.d.ts +8 -0
- package/src/esm/utils/algorithms/arrayShuffle.js +11 -0
- package/src/esm/utils/algorithms/arrayShuffle.js.map +1 -0
- package/src/esm/utils/algorithms/detectPaths.d.ts +20 -0
- package/src/esm/utils/algorithms/detectPaths.js +165 -0
- package/src/esm/utils/algorithms/detectPaths.js.map +1 -0
- package/src/esm/utils/datastructures/GenericPath.d.ts +75 -0
- package/src/esm/utils/datastructures/GenericPath.js +100 -0
- package/src/esm/utils/datastructures/GenericPath.js.map +1 -0
- package/src/esm/utils/datastructures/GirihTile.d.ts +1 -1
- package/src/ts/Bounds.ts +14 -1
- package/src/ts/CubicBezierCurve.ts +29 -4
- package/src/ts/Line.ts +70 -6
- package/src/ts/PlotBoilerplate.ts +47 -32
- package/src/ts/Polygon.ts +1 -1
- package/src/ts/Vector.ts +24 -4
- package/src/ts/interfaces/additionals.ts +105 -0
- package/src/ts/interfaces/core.ts +2 -0
- package/src/ts/interfaces/index.ts +1 -0
- package/src/ts/utils/algorithms/arrayShuffle.ts +11 -0
- package/src/ts/utils/algorithms/detectPaths.ts +195 -0
- package/src/ts/utils/datastructures/GenericPath.ts +113 -0
- package/src/ts/utils/datastructures/GirihTile.ts +1 -1
- package/changelog.md +0 -731
package/dist/plotboilerplate.js
CHANGED
|
@@ -1682,7 +1682,8 @@ exports.BezierPath = BezierPath;
|
|
|
1682
1682
|
* @modified 2021-02-02 Added the `toPolygon` method.
|
|
1683
1683
|
* @modified 2021-06-21 (mid-summer) Added `getCenter` method.
|
|
1684
1684
|
* @modified 2022-02-01 Added the `toString` function.
|
|
1685
|
-
* @
|
|
1685
|
+
* @modified 2022-10-09 Added the `fromDimension` function.
|
|
1686
|
+
* @version 1.5.0
|
|
1686
1687
|
**/
|
|
1687
1688
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1688
1689
|
exports.Bounds = void 0;
|
|
@@ -1788,6 +1789,17 @@ var Bounds = /** @class */ (function () {
|
|
|
1788
1789
|
}
|
|
1789
1790
|
return new Bounds(new Vertex_1.Vertex(xMin, yMin), new Vertex_1.Vertex(xMax, yMax));
|
|
1790
1791
|
};
|
|
1792
|
+
/**
|
|
1793
|
+
* Create a new `Bounds` instance just from `width` and `height`, located at (0,0) or the optionally given origin.
|
|
1794
|
+
*
|
|
1795
|
+
* @param {number} width - The width of the bounds
|
|
1796
|
+
* @param {number} height - The height of the bounds
|
|
1797
|
+
* @param {XYCoords={x:0,y:0}} origin - [optional] A origin to locate the new Bounds object at.
|
|
1798
|
+
* @returns {Bounds} A new `Bounds` instance width given width and height, located at (0,0) or the given origin..
|
|
1799
|
+
*/
|
|
1800
|
+
Bounds.fromDimension = function (width, height, origin) {
|
|
1801
|
+
return new Bounds(origin !== null && origin !== void 0 ? origin : { x: 0, y: 0 }, { x: (origin ? origin.x : 0) + width, y: (origin ? origin.y : 0) + height });
|
|
1802
|
+
};
|
|
1791
1803
|
return Bounds;
|
|
1792
1804
|
}()); // END class bounds
|
|
1793
1805
|
exports.Bounds = Bounds;
|
|
@@ -2201,7 +2213,8 @@ exports.CircleSector = CircleSector;
|
|
|
2201
2213
|
* @modified 2021-01-20 Added UID.
|
|
2202
2214
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
2203
2215
|
* @modified 2022-02-02 Cleared the `toSVGPathData` function (deprecated). Use `drawutilssvg` instead.
|
|
2204
|
-
* @
|
|
2216
|
+
* @modified 2022-10-17 The `CubicBezierCurve` class now implements the new `PathSegment` interface.
|
|
2217
|
+
* @version 2.7.1
|
|
2205
2218
|
*
|
|
2206
2219
|
* @file CubicBezierCurve
|
|
2207
2220
|
* @public
|
|
@@ -2253,7 +2266,7 @@ var CubicBezierCurve = /** @class */ (function () {
|
|
|
2253
2266
|
// An array of floats
|
|
2254
2267
|
this.segmentLengths = [];
|
|
2255
2268
|
// float
|
|
2256
|
-
this.arcLength = null;
|
|
2269
|
+
// this.arcLength = null;
|
|
2257
2270
|
this.updateArcLengths();
|
|
2258
2271
|
}
|
|
2259
2272
|
/**
|
|
@@ -2685,6 +2698,28 @@ var CubicBezierCurve = /** @class */ (function () {
|
|
|
2685
2698
|
CubicBezierCurve.prototype.clone = function () {
|
|
2686
2699
|
return new CubicBezierCurve(this.getStartPoint().clone(), this.getEndPoint().clone(), this.getStartControlPoint().clone(), this.getEndControlPoint().clone());
|
|
2687
2700
|
};
|
|
2701
|
+
//---BEGIN PathSegment-------------------------
|
|
2702
|
+
/**
|
|
2703
|
+
* Get the tangent's end point at the start point of this segment.
|
|
2704
|
+
*
|
|
2705
|
+
* @method getStartTangent
|
|
2706
|
+
* @memberof PathSegment
|
|
2707
|
+
* @return {Vertex} The end point of the starting point's tangent.
|
|
2708
|
+
*/
|
|
2709
|
+
CubicBezierCurve.prototype.getStartTangent = function () {
|
|
2710
|
+
return this.startControlPoint;
|
|
2711
|
+
};
|
|
2712
|
+
/**
|
|
2713
|
+
* Get the tangent's end point at the end point of this segment.
|
|
2714
|
+
*
|
|
2715
|
+
* @method getEndTangent
|
|
2716
|
+
* @memberof PathSegment
|
|
2717
|
+
* @return {Vertex} The end point of the ending point's tangent.
|
|
2718
|
+
*/
|
|
2719
|
+
CubicBezierCurve.prototype.getEndTangent = function () {
|
|
2720
|
+
return this.endControlPoint;
|
|
2721
|
+
};
|
|
2722
|
+
//---END PathSegment-------------------------
|
|
2688
2723
|
/**
|
|
2689
2724
|
* Check if this and the specified curve are equal.<br>
|
|
2690
2725
|
* <br>
|
|
@@ -3410,7 +3445,9 @@ exports.KeyHandler = KeyHandler;
|
|
|
3410
3445
|
* @modified 2020-03-23 Ported to Typescript from JS.
|
|
3411
3446
|
* @modified 2020-12-04 The `intersection` function returns undefined if both lines are parallel.
|
|
3412
3447
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
3413
|
-
* @
|
|
3448
|
+
* @modified 2022-10-09 Changed the actual return value of the `intersection` function to null (was undefined before).
|
|
3449
|
+
* @modified 2022-10-17 Adding these methods from the `PathSegment` interface: getStartPoint, getEndPoint, revert.
|
|
3450
|
+
* @version 2.3.0
|
|
3414
3451
|
*
|
|
3415
3452
|
* @file Line
|
|
3416
3453
|
* @public
|
|
@@ -3470,8 +3507,9 @@ var Line = /** @class */ (function (_super) {
|
|
|
3470
3507
|
// !!! DO NOT MOVE TO VertTuple
|
|
3471
3508
|
Line.prototype.intersection = function (line) {
|
|
3472
3509
|
var denominator = this.denominator(line);
|
|
3473
|
-
if (denominator == 0)
|
|
3510
|
+
if (denominator == 0) {
|
|
3474
3511
|
return null;
|
|
3512
|
+
}
|
|
3475
3513
|
var a = this.a.y - line.a.y;
|
|
3476
3514
|
var b = this.a.x - line.a.x;
|
|
3477
3515
|
var numerator1 = (line.b.x - line.a.x) * a - (line.b.y - line.a.y) * b;
|
|
@@ -3482,11 +3520,65 @@ var Line = /** @class */ (function (_super) {
|
|
|
3482
3520
|
var x = this.a.x + a * (this.b.x - this.a.x);
|
|
3483
3521
|
var y = this.a.y + a * (this.b.y - this.a.y);
|
|
3484
3522
|
if (isNaN(a) || isNaN(x) || isNaN(y)) {
|
|
3485
|
-
return
|
|
3523
|
+
return null;
|
|
3486
3524
|
}
|
|
3487
3525
|
// if we cast these lines infinitely in both directions, they intersect here:
|
|
3488
3526
|
return new Vertex_1.Vertex(x, y);
|
|
3489
3527
|
};
|
|
3528
|
+
//--- Implement PathSegment ---
|
|
3529
|
+
/**
|
|
3530
|
+
* Get the start point of this path segment.
|
|
3531
|
+
*
|
|
3532
|
+
* @method getStartPoint
|
|
3533
|
+
* @memberof PathSegment
|
|
3534
|
+
* @return {Vertex} The start point of this path segment.
|
|
3535
|
+
*/
|
|
3536
|
+
Line.prototype.getStartPoint = function () {
|
|
3537
|
+
return this.a;
|
|
3538
|
+
};
|
|
3539
|
+
/**
|
|
3540
|
+
* Get the end point of this path segment.
|
|
3541
|
+
*
|
|
3542
|
+
* @method getEndPoint
|
|
3543
|
+
* @memberof PathSegment
|
|
3544
|
+
* @return {Vertex} The end point of this path segment.
|
|
3545
|
+
*/
|
|
3546
|
+
Line.prototype.getEndPoint = function () {
|
|
3547
|
+
return this.b;
|
|
3548
|
+
};
|
|
3549
|
+
/**
|
|
3550
|
+
* Get the tangent's end point at the start point of this segment.
|
|
3551
|
+
*
|
|
3552
|
+
* @method getStartTangent
|
|
3553
|
+
* @memberof PathSegment
|
|
3554
|
+
* @return {Vertex} The end point of the starting point's tangent.
|
|
3555
|
+
*/
|
|
3556
|
+
Line.prototype.getStartTangent = function () {
|
|
3557
|
+
return this.b;
|
|
3558
|
+
};
|
|
3559
|
+
/**
|
|
3560
|
+
* Get the tangent's end point at the end point of this segment.
|
|
3561
|
+
*
|
|
3562
|
+
* @method getEndTangent
|
|
3563
|
+
* @memberof PathSegment
|
|
3564
|
+
* @return {Vertex} The end point of the ending point's tangent.
|
|
3565
|
+
*/
|
|
3566
|
+
Line.prototype.getEndTangent = function () {
|
|
3567
|
+
return this.a;
|
|
3568
|
+
};
|
|
3569
|
+
/**
|
|
3570
|
+
* Inverse this path segment (in-place) and return this same instance (useful for chaining).
|
|
3571
|
+
*
|
|
3572
|
+
* @method reverse
|
|
3573
|
+
* @memberof PathSegment
|
|
3574
|
+
* @return {PathSegment} This path segment instance (for chaining).
|
|
3575
|
+
*/
|
|
3576
|
+
Line.prototype.reverse = function () {
|
|
3577
|
+
var tmp = this.a;
|
|
3578
|
+
this.a = this.b;
|
|
3579
|
+
this.b = tmp;
|
|
3580
|
+
return this;
|
|
3581
|
+
};
|
|
3490
3582
|
return Line;
|
|
3491
3583
|
}(VertTuple_1.VertTuple));
|
|
3492
3584
|
exports.Line = Line;
|
|
@@ -4138,7 +4230,9 @@ var __webpack_unused_export__;
|
|
|
4138
4230
|
* @modified 2021-04-25 Extending `remove` to accept arrays of drawables.
|
|
4139
4231
|
* @modified 2021-11-16 Adding the `PBText` drawable.
|
|
4140
4232
|
* @modified 2022-08-01 Added `title` to the params.
|
|
4141
|
-
* @
|
|
4233
|
+
* @modified 2022-10-25 Added the `origin` to the default draw config.
|
|
4234
|
+
* @modified 2022-11-06 Adding an XML declaration to the SVG export routine.
|
|
4235
|
+
* @version 1.16.0
|
|
4142
4236
|
*
|
|
4143
4237
|
* @file PlotBoilerplate
|
|
4144
4238
|
* @fileoverview The main class.
|
|
@@ -4256,6 +4350,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4256
4350
|
* @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
|
|
4257
4351
|
*/
|
|
4258
4352
|
function PlotBoilerplate(config) {
|
|
4353
|
+
var _a, _b;
|
|
4259
4354
|
/**
|
|
4260
4355
|
* A discrete timestamp to identify single render cycles.
|
|
4261
4356
|
* Note that using system time milliseconds is not a safe way to identify render frames, as on modern powerful machines
|
|
@@ -4412,6 +4507,9 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4412
4507
|
lineWidth: 1,
|
|
4413
4508
|
fill: true,
|
|
4414
4509
|
anchor: true
|
|
4510
|
+
},
|
|
4511
|
+
origin: {
|
|
4512
|
+
color: "#000000"
|
|
4415
4513
|
}
|
|
4416
4514
|
}; // END drawConfig
|
|
4417
4515
|
// +---------------------------------------------------------------------------------
|
|
@@ -4430,6 +4528,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4430
4528
|
this.config.enableGL = false;
|
|
4431
4529
|
}
|
|
4432
4530
|
if (this.config.enableGL) {
|
|
4531
|
+
// Override the case 'null' here. If GL is not supported, well then nothing works.
|
|
4433
4532
|
var ctx = this.canvas.getContext("webgl"); // webgl-experimental?
|
|
4434
4533
|
this.draw = new drawgl_1.drawutilsgl(ctx, false);
|
|
4435
4534
|
// PROBLEM: same instance of fill and draw when using WebGL.
|
|
@@ -4438,6 +4537,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4438
4537
|
console.warn("Initialized with experimental mode enableGL=true. Note that this is not yet fully implemented.");
|
|
4439
4538
|
}
|
|
4440
4539
|
else {
|
|
4540
|
+
// Override the case 'null' here. If context creation is not supported, well then nothing works.
|
|
4441
4541
|
var ctx = this.canvas.getContext("2d");
|
|
4442
4542
|
this.draw = new draw_1.drawutils(ctx, false);
|
|
4443
4543
|
this.fill = new draw_1.drawutils(ctx, true);
|
|
@@ -4474,8 +4574,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4474
4574
|
if (config.title) {
|
|
4475
4575
|
this.eventCatcher.setAttribute("title", config.title);
|
|
4476
4576
|
}
|
|
4477
|
-
this.draw.scale.set(this.config.scaleX, this.config.scaleY);
|
|
4478
|
-
this.fill.scale.set(this.config.scaleX, this.config.scaleY);
|
|
4577
|
+
this.draw.scale.set((_a = this.config.scaleX) !== null && _a !== void 0 ? _a : 1.0, this.config.scaleY);
|
|
4578
|
+
this.fill.scale.set((_b = this.config.scaleX) !== null && _b !== void 0 ? _b : 1.0, this.config.scaleY);
|
|
4479
4579
|
this.vertices = [];
|
|
4480
4580
|
this.selectPolygon = null;
|
|
4481
4581
|
this.draggedElements = [];
|
|
@@ -4520,11 +4620,13 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4520
4620
|
var tosvgFill = tosvgDraw.copyInstance(true); // fillShapes=true
|
|
4521
4621
|
tosvgDraw.beginDrawCycle(0);
|
|
4522
4622
|
tosvgFill.beginDrawCycle(0);
|
|
4523
|
-
if (pb.config.preClear)
|
|
4623
|
+
if (pb.config.preClear) {
|
|
4524
4624
|
pb.config.preClear();
|
|
4525
|
-
|
|
4526
|
-
|
|
4625
|
+
}
|
|
4626
|
+
tosvgDraw.clear(pb.config.backgroundColor || "white");
|
|
4627
|
+
if (pb.config.preDraw) {
|
|
4527
4628
|
pb.config.preDraw(tosvgDraw, tosvgFill);
|
|
4629
|
+
}
|
|
4528
4630
|
pb.drawAll(0, tosvgDraw, tosvgFill);
|
|
4529
4631
|
pb.drawVertices(0, tosvgDraw);
|
|
4530
4632
|
if (pb.config.postDraw)
|
|
@@ -4535,7 +4637,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4535
4637
|
// https://caniuse.com/xml-serializer
|
|
4536
4638
|
var serializer = new XMLSerializer();
|
|
4537
4639
|
var svgCode = serializer.serializeToString(svgNode);
|
|
4538
|
-
|
|
4640
|
+
// Add: '<?xml version="1.0" encoding="utf-8"?>\n' ?
|
|
4641
|
+
var blob = new Blob(['<?xml version="1.0" encoding="utf-8"?>\n' + svgCode], { type: "image/svg;charset=utf-8" });
|
|
4539
4642
|
// See documentation for FileSaver.js for usage.
|
|
4540
4643
|
// https://github.com/eligrey/FileSaver.js
|
|
4541
4644
|
if (typeof globalThis["saveAs"] !== "function")
|
|
@@ -4610,11 +4713,12 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4610
4713
|
* @private
|
|
4611
4714
|
**/
|
|
4612
4715
|
PlotBoilerplate.prototype.updateCSSscale = function () {
|
|
4716
|
+
var _a, _b, _c, _d;
|
|
4613
4717
|
if (this.config.cssUniformScale) {
|
|
4614
|
-
PlotBoilerplate.utils.setCSSscale(this.canvas, this.config.cssScaleX, this.config.cssScaleX);
|
|
4718
|
+
PlotBoilerplate.utils.setCSSscale(this.canvas, (_a = this.config.cssScaleX) !== null && _a !== void 0 ? _a : 1.0, (_b = this.config.cssScaleX) !== null && _b !== void 0 ? _b : 1.0);
|
|
4615
4719
|
}
|
|
4616
4720
|
else {
|
|
4617
|
-
PlotBoilerplate.utils.setCSSscale(this.canvas, this.config.cssScaleX, this.config.cssScaleY);
|
|
4721
|
+
PlotBoilerplate.utils.setCSSscale(this.canvas, (_c = this.config.cssScaleX) !== null && _c !== void 0 ? _c : 1.0, (_d = this.config.cssScaleY) !== null && _d !== void 0 ? _d : 1.0);
|
|
4618
4722
|
}
|
|
4619
4723
|
};
|
|
4620
4724
|
/**
|
|
@@ -4887,7 +4991,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4887
4991
|
* @return The vertex near the given position or undefined if none was found there.
|
|
4888
4992
|
**/
|
|
4889
4993
|
PlotBoilerplate.prototype.getVertexNear = function (pixelPosition, pixelTolerance) {
|
|
4890
|
-
var
|
|
4994
|
+
var _a, _b;
|
|
4995
|
+
var p = this.locatePointNear(this.transformMousePosition(pixelPosition.x, pixelPosition.y), pixelTolerance / Math.min((_a = this.config.cssScaleX) !== null && _a !== void 0 ? _a : 1.0, (_b = this.config.cssScaleY) !== null && _b !== void 0 ? _b : 1.0));
|
|
4891
4996
|
if (p && p.typeName == "vertex") {
|
|
4892
4997
|
return this.vertices[p.vindex];
|
|
4893
4998
|
}
|
|
@@ -4953,7 +5058,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4953
5058
|
PlotBoilerplate.prototype.drawOrigin = function (draw) {
|
|
4954
5059
|
// Add a crosshair to mark the origin
|
|
4955
5060
|
draw.setCurrentId("origin");
|
|
4956
|
-
draw.crosshair({ x: 0, y: 0 }, 10,
|
|
5061
|
+
draw.crosshair({ x: 0, y: 0 }, 10, this.drawConfig.origin.color);
|
|
4957
5062
|
};
|
|
4958
5063
|
/**
|
|
4959
5064
|
* This is just a tiny helper function to determine the render color of vertices.
|
|
@@ -5170,10 +5275,10 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5170
5275
|
else {
|
|
5171
5276
|
console.error("Cannot draw object. Unknown class.");
|
|
5172
5277
|
}
|
|
5173
|
-
draw.setCurrentClassName(
|
|
5174
|
-
draw.setCurrentId(
|
|
5175
|
-
fill.setCurrentClassName(
|
|
5176
|
-
fill.setCurrentId(
|
|
5278
|
+
draw.setCurrentClassName(undefined);
|
|
5279
|
+
draw.setCurrentId(undefined);
|
|
5280
|
+
fill.setCurrentClassName(undefined);
|
|
5281
|
+
fill.setCurrentId(undefined);
|
|
5177
5282
|
};
|
|
5178
5283
|
/**
|
|
5179
5284
|
* Draw the select-polygon (if there is one).
|
|
@@ -5276,7 +5381,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5276
5381
|
**/
|
|
5277
5382
|
PlotBoilerplate.prototype.clear = function () {
|
|
5278
5383
|
// Note that elements might have an alpha channel. Clear the scene first.
|
|
5279
|
-
this.draw.clear(this.config.backgroundColor);
|
|
5384
|
+
this.draw.clear(this.config.backgroundColor || "white");
|
|
5280
5385
|
};
|
|
5281
5386
|
/**
|
|
5282
5387
|
* Clear the selection.<br>
|
|
@@ -5306,7 +5411,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5306
5411
|
* @return {Bounds} The current viewport.
|
|
5307
5412
|
**/
|
|
5308
5413
|
PlotBoilerplate.prototype.viewport = function () {
|
|
5309
|
-
|
|
5414
|
+
var _a, _b;
|
|
5415
|
+
return new Bounds_1.Bounds(this.transformMousePosition(0, 0), this.transformMousePosition(this.canvasSize.width * ((_a = this.config.cssScaleX) !== null && _a !== void 0 ? _a : 1.0), this.canvasSize.height * ((_b = this.config.cssScaleY) !== null && _b !== void 0 ? _b : 1.0)));
|
|
5310
5416
|
};
|
|
5311
5417
|
/**
|
|
5312
5418
|
* Trigger the saveFile.hook.
|
|
@@ -5355,10 +5461,12 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5355
5461
|
**/
|
|
5356
5462
|
PlotBoilerplate.prototype.resizeCanvas = function () {
|
|
5357
5463
|
var _this = this;
|
|
5464
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5358
5465
|
var _self = this;
|
|
5359
5466
|
var _setSize = function (w, h) {
|
|
5360
|
-
|
|
5361
|
-
|
|
5467
|
+
var _a, _b;
|
|
5468
|
+
w *= (_a = _self.config.canvasWidthFactor) !== null && _a !== void 0 ? _a : 1.0;
|
|
5469
|
+
h *= (_b = _self.config.canvasHeightFactor) !== null && _b !== void 0 ? _b : 1.0;
|
|
5362
5470
|
_self.canvasSize.width = w;
|
|
5363
5471
|
_self.canvasSize.height = h;
|
|
5364
5472
|
if (_self.canvas instanceof HTMLCanvasElement) {
|
|
@@ -5387,8 +5495,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5387
5495
|
var width = globalThis.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
5388
5496
|
var height = globalThis.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
5389
5497
|
_self.canvas.style.position = "absolute";
|
|
5390
|
-
_self.canvas.style.width = _self.config.canvasWidthFactor * width + "px";
|
|
5391
|
-
_self.canvas.style.height = _self.config.canvasWidthFactor * height + "px";
|
|
5498
|
+
_self.canvas.style.width = ((_a = _self.config.canvasWidthFactor) !== null && _a !== void 0 ? _a : 1.0) * width + "px";
|
|
5499
|
+
_self.canvas.style.height = ((_b = _self.config.canvasWidthFactor) !== null && _b !== void 0 ? _b : 1.0) * height + "px";
|
|
5392
5500
|
_self.canvas.style.top = "0px";
|
|
5393
5501
|
_self.canvas.style.left = "0px";
|
|
5394
5502
|
_setSize(width, height);
|
|
@@ -5397,16 +5505,16 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5397
5505
|
// Set editor size
|
|
5398
5506
|
_self.canvas.style.position = "absolute";
|
|
5399
5507
|
var space = this.getAvailableContainerSpace();
|
|
5400
|
-
_self.canvas.style.width = _self.config.canvasWidthFactor * space.width + "px";
|
|
5401
|
-
_self.canvas.style.height = _self.config.canvasHeightFactor * space.height + "px";
|
|
5402
|
-
_self.canvas.style.top =
|
|
5403
|
-
_self.canvas.style.left =
|
|
5508
|
+
_self.canvas.style.width = ((_c = _self.config.canvasWidthFactor) !== null && _c !== void 0 ? _c : 1.0) * space.width + "px";
|
|
5509
|
+
_self.canvas.style.height = ((_d = _self.config.canvasHeightFactor) !== null && _d !== void 0 ? _d : 1.0) * space.height + "px";
|
|
5510
|
+
_self.canvas.style.top = "";
|
|
5511
|
+
_self.canvas.style.left = "";
|
|
5404
5512
|
_setSize(space.width, space.height);
|
|
5405
5513
|
}
|
|
5406
5514
|
else {
|
|
5407
|
-
_self.canvas.style.width =
|
|
5408
|
-
_self.canvas.style.height =
|
|
5409
|
-
_setSize(_self.config.defaultCanvasWidth, _self.config.defaultCanvasHeight);
|
|
5515
|
+
_self.canvas.style.width = "";
|
|
5516
|
+
_self.canvas.style.height = "";
|
|
5517
|
+
_setSize((_e = _self.config.defaultCanvasWidth) !== null && _e !== void 0 ? _e : 1024, (_f = _self.config.defaultCanvasHeight) !== null && _f !== void 0 ? _f : 768);
|
|
5410
5518
|
}
|
|
5411
5519
|
if (_self.config.redrawOnResize)
|
|
5412
5520
|
_self.redraw();
|
|
@@ -6235,7 +6343,7 @@ var Polygon = /** @class */ (function () {
|
|
|
6235
6343
|
if (typeof vertices == "undefined")
|
|
6236
6344
|
vertices = [];
|
|
6237
6345
|
this.vertices = vertices;
|
|
6238
|
-
this.isOpen = isOpen;
|
|
6346
|
+
this.isOpen = isOpen || false;
|
|
6239
6347
|
}
|
|
6240
6348
|
/**
|
|
6241
6349
|
* Add a vertex to the end of the `vertices` array.
|
|
@@ -7819,7 +7927,8 @@ exports.VEllipseSector = VEllipseSector;
|
|
|
7819
7927
|
* @modified 2021-01-20 Added UID.
|
|
7820
7928
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
7821
7929
|
* @modified 2022-02-02 Cleared the `Vector.toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
7822
|
-
* @
|
|
7930
|
+
* @modified 2022-10-25 Added the `getOrthogonal` method.
|
|
7931
|
+
* @version 1.5.0
|
|
7823
7932
|
*
|
|
7824
7933
|
* @file Vector
|
|
7825
7934
|
* @public
|
|
@@ -7884,7 +7993,7 @@ var Vector = /** @class */ (function (_super) {
|
|
|
7884
7993
|
return v;
|
|
7885
7994
|
};
|
|
7886
7995
|
/**
|
|
7887
|
-
* The inverse of a vector is a vector
|
|
7996
|
+
* The inverse of a vector is a vector with the same magnitude but oppose direction.
|
|
7888
7997
|
*
|
|
7889
7998
|
* Please not that the origin of this vector changes here: a->b becomes b->a.
|
|
7890
7999
|
*
|
|
@@ -7930,6 +8039,24 @@ var Vector = /** @class */ (function (_super) {
|
|
|
7930
8039
|
// if we cast these lines infinitely in both directions, they intersect here:
|
|
7931
8040
|
return new Vertex_1.Vertex(this.a.x + a * (this.b.x - this.a.x), this.a.y + a * (this.b.y - this.a.y));
|
|
7932
8041
|
};
|
|
8042
|
+
/**
|
|
8043
|
+
* Get the orthogonal "vector" of this vector (rotated by 90° clockwise).
|
|
8044
|
+
*
|
|
8045
|
+
* @name getOrthogonal
|
|
8046
|
+
* @method getOrthogonal
|
|
8047
|
+
* @return {Vector} A new vector with the same length that stands on this vector's point a.
|
|
8048
|
+
* @instance
|
|
8049
|
+
* @memberof Vector
|
|
8050
|
+
**/
|
|
8051
|
+
Vector.prototype.getOrthogonal = function () {
|
|
8052
|
+
// Orthogonal of vector (0,0)->(x,y) is (0,0)->(-y,x)
|
|
8053
|
+
var linePoint = this.a.clone();
|
|
8054
|
+
var startPoint = this.b.clone().sub(this.a);
|
|
8055
|
+
var tmp = startPoint.x;
|
|
8056
|
+
startPoint.x = -startPoint.y;
|
|
8057
|
+
startPoint.y = tmp;
|
|
8058
|
+
return new Vector(linePoint, startPoint.add(this.a));
|
|
8059
|
+
};
|
|
7933
8060
|
Vector.utils = {
|
|
7934
8061
|
/**
|
|
7935
8062
|
* Generate a four-point arrow head, starting at the vector end minus the
|