plotboilerplate 1.17.1 → 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/README.md +63 -6
- package/dist/index.esm.js +278 -60
- 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 +276 -58
- 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/Circle.d.ts +36 -2
- package/src/cjs/Circle.js +81 -1
- package/src/cjs/Circle.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/MouseHandler.d.ts +3 -2
- package/src/cjs/MouseHandler.js +16 -14
- package/src/cjs/MouseHandler.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/draw.d.ts +4 -1
- package/src/cjs/draw.js +15 -6
- package/src/cjs/draw.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/Circle.d.ts +36 -2
- package/src/esm/Circle.js +81 -1
- package/src/esm/Circle.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/MouseHandler.d.ts +3 -2
- package/src/esm/MouseHandler.js +16 -14
- package/src/esm/MouseHandler.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/draw.d.ts +4 -1
- package/src/esm/draw.js +15 -6
- package/src/esm/draw.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/Circle.ts +92 -2
- package/src/ts/CubicBezierCurve.ts +29 -4
- package/src/ts/Line.ts +70 -6
- package/src/ts/MouseHandler.ts +16 -15
- package/src/ts/PlotBoilerplate.ts +47 -32
- package/src/ts/Polygon.ts +1 -1
- package/src/ts/Vector.ts +24 -4
- package/src/ts/draw.ts +15 -6
- 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 -722
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;
|
|
@@ -1810,7 +1822,10 @@ exports.Bounds = Bounds;
|
|
|
1810
1822
|
* @modified 2021-01-20 Added UID.
|
|
1811
1823
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
1812
1824
|
* @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
1813
|
-
* @
|
|
1825
|
+
* @modified 2022-08-15 Added the `containsPoint` function.
|
|
1826
|
+
* @modified 2022-08-23 Added the `lineIntersection` function.
|
|
1827
|
+
* @modified 2022-08-23 Added the `closestPoint` function.
|
|
1828
|
+
* @version 1.4.0
|
|
1814
1829
|
**/
|
|
1815
1830
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1816
1831
|
exports.Circle = void 0;
|
|
@@ -1847,6 +1862,18 @@ var Circle = /** @class */ (function () {
|
|
|
1847
1862
|
this.center = center;
|
|
1848
1863
|
this.radius = radius;
|
|
1849
1864
|
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Check if the given circle is fully contained inside this circle.
|
|
1867
|
+
*
|
|
1868
|
+
* @method containsPoint
|
|
1869
|
+
* @param {XYCoords} point - The point to check if it is contained in this circle.
|
|
1870
|
+
* @instance
|
|
1871
|
+
* @memberof Circle
|
|
1872
|
+
* @return {boolean} `true` if the given point is inside this circle.
|
|
1873
|
+
*/
|
|
1874
|
+
Circle.prototype.containsPoint = function (point) {
|
|
1875
|
+
return this.center.distance(point) < this.radius;
|
|
1876
|
+
};
|
|
1850
1877
|
/**
|
|
1851
1878
|
* Check if the given circle is fully contained inside this circle.
|
|
1852
1879
|
*
|
|
@@ -1958,6 +1985,71 @@ var Circle = /** @class */ (function () {
|
|
|
1958
1985
|
var y4 = p2.y + (h * (p1.x - p0.x)) / d;
|
|
1959
1986
|
return new Line_1.Line(new Vertex_1.Vertex(x3, y3), new Vertex_1.Vertex(x4, y4));
|
|
1960
1987
|
};
|
|
1988
|
+
/**
|
|
1989
|
+
* Calculate the intersection points (if exists) with the given infinite line (defined by two points).
|
|
1990
|
+
*
|
|
1991
|
+
* @method lineIntersection
|
|
1992
|
+
* @instance
|
|
1993
|
+
* @memberof Circle
|
|
1994
|
+
* @param {Vertex} a- The first of the two points defining the line.
|
|
1995
|
+
* @param {Vertex} b - The second of the two points defining the line.
|
|
1996
|
+
* @return {Line|null} The intersection points (as a line) or null if this circle does not intersect the line given.
|
|
1997
|
+
**/
|
|
1998
|
+
Circle.prototype.lineIntersection = function (a, b) {
|
|
1999
|
+
// Based on the math from
|
|
2000
|
+
// https://mathworld.wolfram.com/Circle-LineIntersection.html
|
|
2001
|
+
var interA = new Vertex_1.Vertex();
|
|
2002
|
+
var interB = new Vertex_1.Vertex();
|
|
2003
|
+
// First do a transformation, because the calculation is based on a cicle at (0,0)
|
|
2004
|
+
var transA = new Vertex_1.Vertex(a).sub(this.center);
|
|
2005
|
+
var transB = new Vertex_1.Vertex(b).sub(this.center);
|
|
2006
|
+
var diff = transA.difference(transB);
|
|
2007
|
+
// There is a special case if diff.y=0, where the intersection is not calcuatable.
|
|
2008
|
+
// Use an non-zero epsilon here to approximate this case.
|
|
2009
|
+
// TODO for the future: find a better solution
|
|
2010
|
+
if (Math.abs(diff.y) === 0) {
|
|
2011
|
+
diff.y = 0.000001;
|
|
2012
|
+
}
|
|
2013
|
+
var dist = transA.distance(transB);
|
|
2014
|
+
var det = transA.x * transB.y - transA.y * transB.x;
|
|
2015
|
+
var distSquared = dist * dist;
|
|
2016
|
+
var radiusSquared = this.radius * this.radius;
|
|
2017
|
+
// Check if circle and line have an intersection at all
|
|
2018
|
+
if (radiusSquared * distSquared - det * det < 0) {
|
|
2019
|
+
return null;
|
|
2020
|
+
}
|
|
2021
|
+
var belowSqrt = this.radius * this.radius * dist * dist - det * det;
|
|
2022
|
+
var sqrt = Math.sqrt(belowSqrt);
|
|
2023
|
+
interA.x = (det * diff.y + Math.sign(diff.y) * diff.x * sqrt) / distSquared;
|
|
2024
|
+
interB.x = (det * diff.y - Math.sign(diff.y) * diff.x * sqrt) / distSquared;
|
|
2025
|
+
interA.y = (-det * diff.x + Math.abs(diff.y) * sqrt) / distSquared;
|
|
2026
|
+
interB.y = (-det * diff.x - Math.abs(diff.y) * sqrt) / distSquared;
|
|
2027
|
+
return new Line_1.Line(interA.add(this.center), interB.add(this.center));
|
|
2028
|
+
// return new Line(interA, interB);
|
|
2029
|
+
};
|
|
2030
|
+
/**
|
|
2031
|
+
* Calculate the closest point on the outline of this circle to the given point.
|
|
2032
|
+
*
|
|
2033
|
+
* @method closestPoint
|
|
2034
|
+
* @instance
|
|
2035
|
+
* @memberof Circle
|
|
2036
|
+
* @param {XYCoords} vert - The point to find the closest circle point for.
|
|
2037
|
+
* @return {Vertex} The closest point on this circle.
|
|
2038
|
+
**/
|
|
2039
|
+
Circle.prototype.closestPoint = function (vert) {
|
|
2040
|
+
var lineIntersection = this.lineIntersection(this.center, vert);
|
|
2041
|
+
if (!lineIntersection) {
|
|
2042
|
+
// Note: this case should not happen as a radial from the center always intersect this circle.
|
|
2043
|
+
return new Vertex_1.Vertex();
|
|
2044
|
+
}
|
|
2045
|
+
// Return closed of both
|
|
2046
|
+
if (lineIntersection.a.distance(vert) < lineIntersection.b.distance(vert)) {
|
|
2047
|
+
return lineIntersection.a;
|
|
2048
|
+
}
|
|
2049
|
+
else {
|
|
2050
|
+
return lineIntersection.b;
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
1961
2053
|
/**
|
|
1962
2054
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
1963
2055
|
* After calling this function the object might not hold valid data any more and
|
|
@@ -2121,7 +2213,8 @@ exports.CircleSector = CircleSector;
|
|
|
2121
2213
|
* @modified 2021-01-20 Added UID.
|
|
2122
2214
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
2123
2215
|
* @modified 2022-02-02 Cleared the `toSVGPathData` function (deprecated). Use `drawutilssvg` instead.
|
|
2124
|
-
* @
|
|
2216
|
+
* @modified 2022-10-17 The `CubicBezierCurve` class now implements the new `PathSegment` interface.
|
|
2217
|
+
* @version 2.7.1
|
|
2125
2218
|
*
|
|
2126
2219
|
* @file CubicBezierCurve
|
|
2127
2220
|
* @public
|
|
@@ -2173,7 +2266,7 @@ var CubicBezierCurve = /** @class */ (function () {
|
|
|
2173
2266
|
// An array of floats
|
|
2174
2267
|
this.segmentLengths = [];
|
|
2175
2268
|
// float
|
|
2176
|
-
this.arcLength = null;
|
|
2269
|
+
// this.arcLength = null;
|
|
2177
2270
|
this.updateArcLengths();
|
|
2178
2271
|
}
|
|
2179
2272
|
/**
|
|
@@ -2605,6 +2698,28 @@ var CubicBezierCurve = /** @class */ (function () {
|
|
|
2605
2698
|
CubicBezierCurve.prototype.clone = function () {
|
|
2606
2699
|
return new CubicBezierCurve(this.getStartPoint().clone(), this.getEndPoint().clone(), this.getStartControlPoint().clone(), this.getEndControlPoint().clone());
|
|
2607
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-------------------------
|
|
2608
2723
|
/**
|
|
2609
2724
|
* Check if this and the specified curve are equal.<br>
|
|
2610
2725
|
* <br>
|
|
@@ -3330,7 +3445,9 @@ exports.KeyHandler = KeyHandler;
|
|
|
3330
3445
|
* @modified 2020-03-23 Ported to Typescript from JS.
|
|
3331
3446
|
* @modified 2020-12-04 The `intersection` function returns undefined if both lines are parallel.
|
|
3332
3447
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
3333
|
-
* @
|
|
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
|
|
3334
3451
|
*
|
|
3335
3452
|
* @file Line
|
|
3336
3453
|
* @public
|
|
@@ -3390,8 +3507,9 @@ var Line = /** @class */ (function (_super) {
|
|
|
3390
3507
|
// !!! DO NOT MOVE TO VertTuple
|
|
3391
3508
|
Line.prototype.intersection = function (line) {
|
|
3392
3509
|
var denominator = this.denominator(line);
|
|
3393
|
-
if (denominator == 0)
|
|
3510
|
+
if (denominator == 0) {
|
|
3394
3511
|
return null;
|
|
3512
|
+
}
|
|
3395
3513
|
var a = this.a.y - line.a.y;
|
|
3396
3514
|
var b = this.a.x - line.a.x;
|
|
3397
3515
|
var numerator1 = (line.b.x - line.a.x) * a - (line.b.y - line.a.y) * b;
|
|
@@ -3402,11 +3520,65 @@ var Line = /** @class */ (function (_super) {
|
|
|
3402
3520
|
var x = this.a.x + a * (this.b.x - this.a.x);
|
|
3403
3521
|
var y = this.a.y + a * (this.b.y - this.a.y);
|
|
3404
3522
|
if (isNaN(a) || isNaN(x) || isNaN(y)) {
|
|
3405
|
-
return
|
|
3523
|
+
return null;
|
|
3406
3524
|
}
|
|
3407
3525
|
// if we cast these lines infinitely in both directions, they intersect here:
|
|
3408
3526
|
return new Vertex_1.Vertex(x, y);
|
|
3409
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
|
+
};
|
|
3410
3582
|
return Line;
|
|
3411
3583
|
}(VertTuple_1.VertTuple));
|
|
3412
3584
|
exports.Line = Line;
|
|
@@ -3437,7 +3609,8 @@ exports.Line = Line;
|
|
|
3437
3609
|
* @modified 2020-10-04 Added extended JSDoc comments.
|
|
3438
3610
|
* @modified 2020-11-25 Added the `isTouchEvent` param.
|
|
3439
3611
|
* @modified 2021-01-10 The mouse handler is now also working with SVGElements.
|
|
3440
|
-
* @
|
|
3612
|
+
* @modified 2022-08-16 Fixed a bug in the mouse button detection.
|
|
3613
|
+
* @version 1.2.1
|
|
3441
3614
|
*
|
|
3442
3615
|
* @file MouseHandler
|
|
3443
3616
|
* @public
|
|
@@ -3554,8 +3727,8 @@ var MouseHandler = /** @class */ (function () {
|
|
|
3554
3727
|
// +-------------------------------------------------
|
|
3555
3728
|
this.name = name;
|
|
3556
3729
|
this.element = element;
|
|
3557
|
-
this.mouseDownPos =
|
|
3558
|
-
this.mouseDragPos =
|
|
3730
|
+
this.mouseDownPos = undefined;
|
|
3731
|
+
this.mouseDragPos = undefined;
|
|
3559
3732
|
// this.mousePos = null;
|
|
3560
3733
|
this.mouseButton = -1;
|
|
3561
3734
|
this.listeners = {};
|
|
@@ -3624,26 +3797,27 @@ var MouseHandler = /** @class */ (function () {
|
|
|
3624
3797
|
* @memberof MouseHandler
|
|
3625
3798
|
* @instance
|
|
3626
3799
|
* @private
|
|
3627
|
-
* @param {MouseEvent}
|
|
3800
|
+
* @param {MouseEvent} event - The mouse event to get the relative position for.
|
|
3628
3801
|
* @param {string} eventName - The name of the firing event.
|
|
3629
3802
|
* @return {XMouseEvent}
|
|
3630
3803
|
*/
|
|
3631
|
-
MouseHandler.prototype.mkParams = function (
|
|
3632
|
-
var
|
|
3633
|
-
var
|
|
3804
|
+
MouseHandler.prototype.mkParams = function (event, eventName) {
|
|
3805
|
+
var _a, _b;
|
|
3806
|
+
var rel = this.relPos(event);
|
|
3807
|
+
var xEvent = event;
|
|
3634
3808
|
xEvent.params = {
|
|
3635
3809
|
element: this.element,
|
|
3636
3810
|
name: eventName,
|
|
3637
3811
|
isTouchEvent: false,
|
|
3638
3812
|
pos: rel,
|
|
3639
|
-
button:
|
|
3640
|
-
leftButton:
|
|
3641
|
-
middleButton:
|
|
3642
|
-
rightButton:
|
|
3643
|
-
mouseDownPos: this.mouseDownPos,
|
|
3644
|
-
draggedFrom: this.mouseDragPos,
|
|
3813
|
+
button: event.button,
|
|
3814
|
+
leftButton: event.button === 0,
|
|
3815
|
+
middleButton: event.button === 1,
|
|
3816
|
+
rightButton: event.button === 2,
|
|
3817
|
+
mouseDownPos: (_a = this.mouseDownPos) !== null && _a !== void 0 ? _a : { x: NaN, y: NaN },
|
|
3818
|
+
draggedFrom: (_b = this.mouseDragPos) !== null && _b !== void 0 ? _b : { x: NaN, y: NaN },
|
|
3645
3819
|
wasDragged: this.mouseDownPos != null && (this.mouseDownPos.x != rel.x || this.mouseDownPos.y != rel.y),
|
|
3646
|
-
dragAmount: this.
|
|
3820
|
+
dragAmount: this.mouseDragPos != null ? { x: rel.x - this.mouseDragPos.x, y: rel.y - this.mouseDragPos.y } : { x: 0, y: 0 }
|
|
3647
3821
|
};
|
|
3648
3822
|
return xEvent;
|
|
3649
3823
|
};
|
|
@@ -4056,7 +4230,9 @@ var __webpack_unused_export__;
|
|
|
4056
4230
|
* @modified 2021-04-25 Extending `remove` to accept arrays of drawables.
|
|
4057
4231
|
* @modified 2021-11-16 Adding the `PBText` drawable.
|
|
4058
4232
|
* @modified 2022-08-01 Added `title` to the params.
|
|
4059
|
-
* @
|
|
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
|
|
4060
4236
|
*
|
|
4061
4237
|
* @file PlotBoilerplate
|
|
4062
4238
|
* @fileoverview The main class.
|
|
@@ -4174,6 +4350,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4174
4350
|
* @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
|
|
4175
4351
|
*/
|
|
4176
4352
|
function PlotBoilerplate(config) {
|
|
4353
|
+
var _a, _b;
|
|
4177
4354
|
/**
|
|
4178
4355
|
* A discrete timestamp to identify single render cycles.
|
|
4179
4356
|
* Note that using system time milliseconds is not a safe way to identify render frames, as on modern powerful machines
|
|
@@ -4330,6 +4507,9 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4330
4507
|
lineWidth: 1,
|
|
4331
4508
|
fill: true,
|
|
4332
4509
|
anchor: true
|
|
4510
|
+
},
|
|
4511
|
+
origin: {
|
|
4512
|
+
color: "#000000"
|
|
4333
4513
|
}
|
|
4334
4514
|
}; // END drawConfig
|
|
4335
4515
|
// +---------------------------------------------------------------------------------
|
|
@@ -4348,6 +4528,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4348
4528
|
this.config.enableGL = false;
|
|
4349
4529
|
}
|
|
4350
4530
|
if (this.config.enableGL) {
|
|
4531
|
+
// Override the case 'null' here. If GL is not supported, well then nothing works.
|
|
4351
4532
|
var ctx = this.canvas.getContext("webgl"); // webgl-experimental?
|
|
4352
4533
|
this.draw = new drawgl_1.drawutilsgl(ctx, false);
|
|
4353
4534
|
// PROBLEM: same instance of fill and draw when using WebGL.
|
|
@@ -4356,6 +4537,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4356
4537
|
console.warn("Initialized with experimental mode enableGL=true. Note that this is not yet fully implemented.");
|
|
4357
4538
|
}
|
|
4358
4539
|
else {
|
|
4540
|
+
// Override the case 'null' here. If context creation is not supported, well then nothing works.
|
|
4359
4541
|
var ctx = this.canvas.getContext("2d");
|
|
4360
4542
|
this.draw = new draw_1.drawutils(ctx, false);
|
|
4361
4543
|
this.fill = new draw_1.drawutils(ctx, true);
|
|
@@ -4392,8 +4574,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4392
4574
|
if (config.title) {
|
|
4393
4575
|
this.eventCatcher.setAttribute("title", config.title);
|
|
4394
4576
|
}
|
|
4395
|
-
this.draw.scale.set(this.config.scaleX, this.config.scaleY);
|
|
4396
|
-
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);
|
|
4397
4579
|
this.vertices = [];
|
|
4398
4580
|
this.selectPolygon = null;
|
|
4399
4581
|
this.draggedElements = [];
|
|
@@ -4438,11 +4620,13 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4438
4620
|
var tosvgFill = tosvgDraw.copyInstance(true); // fillShapes=true
|
|
4439
4621
|
tosvgDraw.beginDrawCycle(0);
|
|
4440
4622
|
tosvgFill.beginDrawCycle(0);
|
|
4441
|
-
if (pb.config.preClear)
|
|
4623
|
+
if (pb.config.preClear) {
|
|
4442
4624
|
pb.config.preClear();
|
|
4443
|
-
|
|
4444
|
-
|
|
4625
|
+
}
|
|
4626
|
+
tosvgDraw.clear(pb.config.backgroundColor || "white");
|
|
4627
|
+
if (pb.config.preDraw) {
|
|
4445
4628
|
pb.config.preDraw(tosvgDraw, tosvgFill);
|
|
4629
|
+
}
|
|
4446
4630
|
pb.drawAll(0, tosvgDraw, tosvgFill);
|
|
4447
4631
|
pb.drawVertices(0, tosvgDraw);
|
|
4448
4632
|
if (pb.config.postDraw)
|
|
@@ -4453,7 +4637,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4453
4637
|
// https://caniuse.com/xml-serializer
|
|
4454
4638
|
var serializer = new XMLSerializer();
|
|
4455
4639
|
var svgCode = serializer.serializeToString(svgNode);
|
|
4456
|
-
|
|
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" });
|
|
4457
4642
|
// See documentation for FileSaver.js for usage.
|
|
4458
4643
|
// https://github.com/eligrey/FileSaver.js
|
|
4459
4644
|
if (typeof globalThis["saveAs"] !== "function")
|
|
@@ -4528,11 +4713,12 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4528
4713
|
* @private
|
|
4529
4714
|
**/
|
|
4530
4715
|
PlotBoilerplate.prototype.updateCSSscale = function () {
|
|
4716
|
+
var _a, _b, _c, _d;
|
|
4531
4717
|
if (this.config.cssUniformScale) {
|
|
4532
|
-
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);
|
|
4533
4719
|
}
|
|
4534
4720
|
else {
|
|
4535
|
-
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);
|
|
4536
4722
|
}
|
|
4537
4723
|
};
|
|
4538
4724
|
/**
|
|
@@ -4805,7 +4991,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4805
4991
|
* @return The vertex near the given position or undefined if none was found there.
|
|
4806
4992
|
**/
|
|
4807
4993
|
PlotBoilerplate.prototype.getVertexNear = function (pixelPosition, pixelTolerance) {
|
|
4808
|
-
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));
|
|
4809
4996
|
if (p && p.typeName == "vertex") {
|
|
4810
4997
|
return this.vertices[p.vindex];
|
|
4811
4998
|
}
|
|
@@ -4871,7 +5058,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
4871
5058
|
PlotBoilerplate.prototype.drawOrigin = function (draw) {
|
|
4872
5059
|
// Add a crosshair to mark the origin
|
|
4873
5060
|
draw.setCurrentId("origin");
|
|
4874
|
-
draw.crosshair({ x: 0, y: 0 }, 10,
|
|
5061
|
+
draw.crosshair({ x: 0, y: 0 }, 10, this.drawConfig.origin.color);
|
|
4875
5062
|
};
|
|
4876
5063
|
/**
|
|
4877
5064
|
* This is just a tiny helper function to determine the render color of vertices.
|
|
@@ -5088,10 +5275,10 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5088
5275
|
else {
|
|
5089
5276
|
console.error("Cannot draw object. Unknown class.");
|
|
5090
5277
|
}
|
|
5091
|
-
draw.setCurrentClassName(
|
|
5092
|
-
draw.setCurrentId(
|
|
5093
|
-
fill.setCurrentClassName(
|
|
5094
|
-
fill.setCurrentId(
|
|
5278
|
+
draw.setCurrentClassName(undefined);
|
|
5279
|
+
draw.setCurrentId(undefined);
|
|
5280
|
+
fill.setCurrentClassName(undefined);
|
|
5281
|
+
fill.setCurrentId(undefined);
|
|
5095
5282
|
};
|
|
5096
5283
|
/**
|
|
5097
5284
|
* Draw the select-polygon (if there is one).
|
|
@@ -5194,7 +5381,7 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5194
5381
|
**/
|
|
5195
5382
|
PlotBoilerplate.prototype.clear = function () {
|
|
5196
5383
|
// Note that elements might have an alpha channel. Clear the scene first.
|
|
5197
|
-
this.draw.clear(this.config.backgroundColor);
|
|
5384
|
+
this.draw.clear(this.config.backgroundColor || "white");
|
|
5198
5385
|
};
|
|
5199
5386
|
/**
|
|
5200
5387
|
* Clear the selection.<br>
|
|
@@ -5224,7 +5411,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5224
5411
|
* @return {Bounds} The current viewport.
|
|
5225
5412
|
**/
|
|
5226
5413
|
PlotBoilerplate.prototype.viewport = function () {
|
|
5227
|
-
|
|
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)));
|
|
5228
5416
|
};
|
|
5229
5417
|
/**
|
|
5230
5418
|
* Trigger the saveFile.hook.
|
|
@@ -5273,10 +5461,12 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5273
5461
|
**/
|
|
5274
5462
|
PlotBoilerplate.prototype.resizeCanvas = function () {
|
|
5275
5463
|
var _this = this;
|
|
5464
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5276
5465
|
var _self = this;
|
|
5277
5466
|
var _setSize = function (w, h) {
|
|
5278
|
-
|
|
5279
|
-
|
|
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;
|
|
5280
5470
|
_self.canvasSize.width = w;
|
|
5281
5471
|
_self.canvasSize.height = h;
|
|
5282
5472
|
if (_self.canvas instanceof HTMLCanvasElement) {
|
|
@@ -5305,8 +5495,8 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5305
5495
|
var width = globalThis.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
5306
5496
|
var height = globalThis.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
5307
5497
|
_self.canvas.style.position = "absolute";
|
|
5308
|
-
_self.canvas.style.width = _self.config.canvasWidthFactor * width + "px";
|
|
5309
|
-
_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";
|
|
5310
5500
|
_self.canvas.style.top = "0px";
|
|
5311
5501
|
_self.canvas.style.left = "0px";
|
|
5312
5502
|
_setSize(width, height);
|
|
@@ -5315,16 +5505,16 @@ var PlotBoilerplate = /** @class */ (function () {
|
|
|
5315
5505
|
// Set editor size
|
|
5316
5506
|
_self.canvas.style.position = "absolute";
|
|
5317
5507
|
var space = this.getAvailableContainerSpace();
|
|
5318
|
-
_self.canvas.style.width = _self.config.canvasWidthFactor * space.width + "px";
|
|
5319
|
-
_self.canvas.style.height = _self.config.canvasHeightFactor * space.height + "px";
|
|
5320
|
-
_self.canvas.style.top =
|
|
5321
|
-
_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 = "";
|
|
5322
5512
|
_setSize(space.width, space.height);
|
|
5323
5513
|
}
|
|
5324
5514
|
else {
|
|
5325
|
-
_self.canvas.style.width =
|
|
5326
|
-
_self.canvas.style.height =
|
|
5327
|
-
_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);
|
|
5328
5518
|
}
|
|
5329
5519
|
if (_self.config.redrawOnResize)
|
|
5330
5520
|
_self.redraw();
|
|
@@ -6153,7 +6343,7 @@ var Polygon = /** @class */ (function () {
|
|
|
6153
6343
|
if (typeof vertices == "undefined")
|
|
6154
6344
|
vertices = [];
|
|
6155
6345
|
this.vertices = vertices;
|
|
6156
|
-
this.isOpen = isOpen;
|
|
6346
|
+
this.isOpen = isOpen || false;
|
|
6157
6347
|
}
|
|
6158
6348
|
/**
|
|
6159
6349
|
* Add a vertex to the end of the `vertices` array.
|
|
@@ -7737,7 +7927,8 @@ exports.VEllipseSector = VEllipseSector;
|
|
|
7737
7927
|
* @modified 2021-01-20 Added UID.
|
|
7738
7928
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
7739
7929
|
* @modified 2022-02-02 Cleared the `Vector.toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
7740
|
-
* @
|
|
7930
|
+
* @modified 2022-10-25 Added the `getOrthogonal` method.
|
|
7931
|
+
* @version 1.5.0
|
|
7741
7932
|
*
|
|
7742
7933
|
* @file Vector
|
|
7743
7934
|
* @public
|
|
@@ -7802,7 +7993,7 @@ var Vector = /** @class */ (function (_super) {
|
|
|
7802
7993
|
return v;
|
|
7803
7994
|
};
|
|
7804
7995
|
/**
|
|
7805
|
-
* The inverse of a vector is a vector
|
|
7996
|
+
* The inverse of a vector is a vector with the same magnitude but oppose direction.
|
|
7806
7997
|
*
|
|
7807
7998
|
* Please not that the origin of this vector changes here: a->b becomes b->a.
|
|
7808
7999
|
*
|
|
@@ -7848,6 +8039,24 @@ var Vector = /** @class */ (function (_super) {
|
|
|
7848
8039
|
// if we cast these lines infinitely in both directions, they intersect here:
|
|
7849
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));
|
|
7850
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
|
+
};
|
|
7851
8060
|
Vector.utils = {
|
|
7852
8061
|
/**
|
|
7853
8062
|
* Generate a four-point arrow head, starting at the vector end minus the
|
|
@@ -9202,7 +9411,10 @@ exports.VertexListeners = VertexListeners;
|
|
|
9202
9411
|
* @modified 2022-03-27 Added the `texturedPoly` function.
|
|
9203
9412
|
* @modified 2022-06-01 Tweaked the `polyline` function; lineWidth now scales with scale.x.
|
|
9204
9413
|
* @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
|
|
9205
|
-
* @
|
|
9414
|
+
* @modified 2022-08-23 Fixed a type issue in the `polyline` function.
|
|
9415
|
+
* @modified 2022-08-23 Fixed a type issue in the `setConfiguration` function.
|
|
9416
|
+
* @modified 2022-08-23 Fixed a type issue in the `path` function.
|
|
9417
|
+
* @version 1.12.3
|
|
9206
9418
|
**/
|
|
9207
9419
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9208
9420
|
exports.drawutils = void 0;
|
|
@@ -9261,7 +9473,7 @@ var drawutils = /** @class */ (function () {
|
|
|
9261
9473
|
* @param {DrawLibConfiguration} configuration - The new configuration settings to use for the next render methods.
|
|
9262
9474
|
*/
|
|
9263
9475
|
drawutils.prototype.setConfiguration = function (configuration) {
|
|
9264
|
-
this.ctx.globalCompositeOperation = configuration.blendMode;
|
|
9476
|
+
this.ctx.globalCompositeOperation = configuration.blendMode || "source-over";
|
|
9265
9477
|
};
|
|
9266
9478
|
/**
|
|
9267
9479
|
* This method shouled be called each time the currently drawn `Drawable` changes.
|
|
@@ -9972,7 +10184,7 @@ var drawutils = /** @class */ (function () {
|
|
|
9972
10184
|
}
|
|
9973
10185
|
this.ctx.save();
|
|
9974
10186
|
this.ctx.beginPath();
|
|
9975
|
-
this.ctx.lineWidth = lineWidth * this.scale.x
|
|
10187
|
+
this.ctx.lineWidth = (lineWidth || 1.0) * this.scale.x;
|
|
9976
10188
|
this.ctx.moveTo(this.offset.x + vertices[0].x * this.scale.x, this.offset.y + vertices[0].y * this.scale.y);
|
|
9977
10189
|
for (var i = 0; i < vertices.length; i++) {
|
|
9978
10190
|
this.ctx.lineTo(this.offset.x + vertices[i].x * this.scale.x, this.offset.y + vertices[i].y * this.scale.y);
|
|
@@ -10089,14 +10301,20 @@ var drawutils = /** @class */ (function () {
|
|
|
10089
10301
|
drawutils.prototype.path = function (pathData, color, lineWidth, options) {
|
|
10090
10302
|
var d = options && options.inplace ? pathData : drawutilssvg_1.drawutilssvg.copyPathData(pathData);
|
|
10091
10303
|
drawutilssvg_1.drawutilssvg.transformPathData(d, this.offset, this.scale);
|
|
10092
|
-
|
|
10304
|
+
if (color) {
|
|
10305
|
+
this.ctx.strokeStyle = color;
|
|
10306
|
+
}
|
|
10093
10307
|
this.ctx.lineWidth = lineWidth || 1;
|
|
10094
10308
|
if (this.fillShapes) {
|
|
10095
|
-
|
|
10309
|
+
if (color) {
|
|
10310
|
+
this.ctx.fillStyle = color;
|
|
10311
|
+
}
|
|
10096
10312
|
this.ctx.fill(new Path2D(d.join(" ")));
|
|
10097
10313
|
}
|
|
10098
10314
|
else {
|
|
10099
|
-
|
|
10315
|
+
if (color) {
|
|
10316
|
+
this.ctx.strokeStyle = color;
|
|
10317
|
+
}
|
|
10100
10318
|
this.ctx.stroke(new Path2D(d.join(" ")));
|
|
10101
10319
|
}
|
|
10102
10320
|
};
|