plotboilerplate 1.15.0 → 1.16.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/changelog.md +24 -0
- package/dist/index.esm.js +574 -428
- 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 +574 -428
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/BezierPath.d.ts +33 -1
- package/src/cjs/BezierPath.js +80 -13
- package/src/cjs/BezierPath.js.map +1 -1
- package/src/cjs/Circle.d.ts +25 -10
- package/src/cjs/Circle.js +38 -33
- package/src/cjs/Circle.js.map +1 -1
- package/src/cjs/CircleSector.d.ts +27 -13
- package/src/cjs/CircleSector.js +38 -23
- package/src/cjs/CircleSector.js.map +1 -1
- package/src/cjs/CubicBezierCurve.d.ts +17 -1
- package/src/cjs/CubicBezierCurve.js +78 -79
- package/src/cjs/CubicBezierCurve.js.map +1 -1
- package/src/cjs/KeyHandler.d.ts +10 -3
- package/src/cjs/KeyHandler.js +28 -23
- package/src/cjs/KeyHandler.js.map +1 -1
- package/src/cjs/Line.d.ts +2 -1
- package/src/cjs/Line.js +19 -18
- package/src/cjs/Line.js.map +1 -1
- package/src/cjs/MouseHandler.js +43 -53
- package/src/cjs/MouseHandler.js.map +1 -1
- package/src/cjs/PBImage.d.ts +16 -1
- package/src/cjs/PBImage.js +13 -3
- package/src/cjs/PBImage.js.map +1 -1
- package/src/cjs/PBText.d.ts +15 -1
- package/src/cjs/PBText.js +11 -1
- package/src/cjs/PBText.js.map +1 -1
- package/src/cjs/PlotBoilerplate.js +1 -1
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Polygon.d.ts +16 -1
- package/src/cjs/Polygon.js +37 -23
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/Triangle.d.ts +16 -1
- package/src/cjs/Triangle.js +50 -54
- package/src/cjs/Triangle.js.map +1 -1
- package/src/cjs/VEllipse.d.ts +16 -1
- package/src/cjs/VEllipse.js +25 -12
- package/src/cjs/VEllipse.js.map +1 -1
- package/src/cjs/VEllipseSector.d.ts +15 -1
- package/src/cjs/VEllipseSector.js +11 -1
- package/src/cjs/VEllipseSector.js.map +1 -1
- package/src/cjs/Vector.d.ts +3 -1
- package/src/cjs/Vector.js +32 -36
- package/src/cjs/Vector.js.map +1 -1
- package/src/cjs/VertTuple.d.ts +15 -1
- package/src/cjs/VertTuple.js +14 -19
- package/src/cjs/VertTuple.js.map +1 -1
- package/src/cjs/Vertex.d.ts +25 -1
- package/src/cjs/Vertex.js +38 -11
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/VertexListeners.d.ts +12 -8
- package/src/cjs/VertexListeners.js +18 -25
- package/src/cjs/VertexListeners.js.map +1 -1
- package/src/cjs/utils/creategui.js +1 -1
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +15 -0
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +55 -28
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/cjs/utils/io/DndFileHandler.d.ts +63 -0
- package/src/cjs/utils/io/DndFileHandler.js +112 -0
- package/src/cjs/utils/io/DndFileHandler.js.map +1 -0
- package/src/cjs/utils/io/FileDrop.d.ts +98 -0
- package/src/cjs/utils/io/FileDrop.js +142 -0
- package/src/cjs/utils/io/FileDrop.js.map +1 -0
- package/src/esm/BezierPath.d.ts +33 -1
- package/src/esm/BezierPath.js +80 -13
- package/src/esm/BezierPath.js.map +1 -1
- package/src/esm/Circle.d.ts +25 -10
- package/src/esm/Circle.js +38 -33
- package/src/esm/Circle.js.map +1 -1
- package/src/esm/CircleSector.d.ts +27 -13
- package/src/esm/CircleSector.js +38 -23
- package/src/esm/CircleSector.js.map +1 -1
- package/src/esm/CubicBezierCurve.d.ts +17 -1
- package/src/esm/CubicBezierCurve.js +78 -79
- package/src/esm/CubicBezierCurve.js.map +1 -1
- package/src/esm/KeyHandler.d.ts +10 -3
- package/src/esm/KeyHandler.js +28 -23
- package/src/esm/KeyHandler.js.map +1 -1
- package/src/esm/Line.d.ts +2 -1
- package/src/esm/Line.js +19 -18
- package/src/esm/Line.js.map +1 -1
- package/src/esm/MouseHandler.js +43 -53
- package/src/esm/MouseHandler.js.map +1 -1
- package/src/esm/PBImage.d.ts +16 -1
- package/src/esm/PBImage.js +13 -3
- package/src/esm/PBImage.js.map +1 -1
- package/src/esm/PBText.d.ts +15 -1
- package/src/esm/PBText.js +11 -1
- package/src/esm/PBText.js.map +1 -1
- package/src/esm/PlotBoilerplate.js +1 -1
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Polygon.d.ts +16 -1
- package/src/esm/Polygon.js +37 -23
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/Triangle.d.ts +16 -1
- package/src/esm/Triangle.js +50 -54
- package/src/esm/Triangle.js.map +1 -1
- package/src/esm/VEllipse.d.ts +16 -1
- package/src/esm/VEllipse.js +25 -12
- package/src/esm/VEllipse.js.map +1 -1
- package/src/esm/VEllipseSector.d.ts +15 -1
- package/src/esm/VEllipseSector.js +11 -1
- package/src/esm/VEllipseSector.js.map +1 -1
- package/src/esm/Vector.d.ts +3 -1
- package/src/esm/Vector.js +32 -36
- package/src/esm/Vector.js.map +1 -1
- package/src/esm/VertTuple.d.ts +15 -1
- package/src/esm/VertTuple.js +14 -19
- package/src/esm/VertTuple.js.map +1 -1
- package/src/esm/Vertex.d.ts +25 -1
- package/src/esm/Vertex.js +38 -11
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/VertexListeners.d.ts +12 -8
- package/src/esm/VertexListeners.js +18 -25
- package/src/esm/VertexListeners.js.map +1 -1
- package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +15 -0
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js +54 -28
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/esm/utils/io/DndFileHandler.d.ts +63 -0
- package/src/esm/utils/io/DndFileHandler.js +106 -0
- package/src/esm/utils/io/DndFileHandler.js.map +1 -0
- package/src/esm/utils/io/FileDrop.d.ts +98 -0
- package/src/esm/utils/io/FileDrop.js +136 -0
- package/src/esm/utils/io/FileDrop.js.map +1 -0
- package/src/ts/BezierPath.ts +96 -11
- package/src/ts/Circle.ts +213 -200
- package/src/ts/CircleSector.ts +171 -141
- package/src/ts/CubicBezierCurve.ts +777 -810
- package/src/ts/KeyHandler.ts +221 -212
- package/src/ts/Line.ts +77 -80
- package/src/ts/MouseHandler.ts +356 -368
- package/src/ts/PBImage.ts +81 -68
- package/src/ts/PBText.ts +20 -1
- package/src/ts/PlotBoilerplate.ts +1 -1
- package/src/ts/Polygon.ts +48 -22
- package/src/ts/Triangle.ts +484 -489
- package/src/ts/VEllipse.ts +36 -11
- package/src/ts/VEllipseSector.ts +20 -1
- package/src/ts/Vector.ts +164 -160
- package/src/ts/VertTuple.ts +333 -338
- package/src/ts/Vertex.ts +52 -10
- package/src/ts/VertexListeners.ts +248 -266
- package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +61 -30
- package/src/ts/utils/io/FileDrop.ts +178 -0
package/src/ts/PBImage.ts
CHANGED
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
* @modified 2019-03-23 Added JSDoc tags.
|
|
5
5
|
* @modified 2020-03-25 Ported this class from vanilla-JS to Typescript.
|
|
6
6
|
* @modified 2021-01-20 Added UID.
|
|
7
|
-
* @
|
|
7
|
+
* @modified 2022-02-02 Added the `destroy` method.
|
|
8
|
+
* @modified 2022-02-02 Cleared the `PBImage.toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
9
|
+
* @version 1.2.0
|
|
8
10
|
*
|
|
9
11
|
* @file PBImage
|
|
10
|
-
* @fileoverview As native Image objects have only a position and with
|
|
12
|
+
* @fileoverview As native Image objects have only a position and with
|
|
11
13
|
* and height thei are not suitable for UI dragging interfaces.
|
|
12
14
|
* @public
|
|
13
15
|
**/
|
|
14
16
|
|
|
15
|
-
|
|
16
17
|
import { Vertex } from "./Vertex";
|
|
17
18
|
import { UIDGenerator } from "./UIDGenerator";
|
|
18
19
|
import { SVGSerializable, UID } from "./interfaces";
|
|
19
20
|
|
|
20
|
-
|
|
21
21
|
/**
|
|
22
22
|
* @classdesc A wrapper for image objects. Has an upper left and a lower right corner point.
|
|
23
23
|
*
|
|
@@ -27,76 +27,89 @@ import { SVGSerializable, UID } from "./interfaces";
|
|
|
27
27
|
* @requires UIDGenerator
|
|
28
28
|
*/
|
|
29
29
|
export class PBImage implements SVGSerializable {
|
|
30
|
+
/**
|
|
31
|
+
* Required to generate proper CSS classes and other class related IDs.
|
|
32
|
+
**/
|
|
33
|
+
readonly className: string = "PBImage";
|
|
30
34
|
|
|
35
|
+
/**
|
|
36
|
+
* The UID of this drawable object.
|
|
37
|
+
*
|
|
38
|
+
* @member {UID}
|
|
39
|
+
* @memberof PBImage
|
|
40
|
+
* @instance
|
|
41
|
+
* @readonly
|
|
42
|
+
*/
|
|
43
|
+
readonly uid: UID;
|
|
31
44
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
/**
|
|
46
|
+
* @member {Vertex}
|
|
47
|
+
* @memberof PBImage
|
|
48
|
+
* @instance
|
|
49
|
+
*/
|
|
50
|
+
image: HTMLImageElement;
|
|
36
51
|
|
|
52
|
+
/**
|
|
53
|
+
* @member {Vertex}
|
|
54
|
+
* @memberof PBImage
|
|
55
|
+
* @instance
|
|
56
|
+
*/
|
|
57
|
+
upperLeft: Vertex;
|
|
37
58
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* @readonly
|
|
45
|
-
*/
|
|
46
|
-
readonly uid : UID;
|
|
47
|
-
|
|
59
|
+
/**
|
|
60
|
+
* @member {Vertex}
|
|
61
|
+
* @memberof PBImage
|
|
62
|
+
* @instance
|
|
63
|
+
*/
|
|
64
|
+
lowerRight: Vertex;
|
|
48
65
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @member isDestroyed
|
|
68
|
+
* @memberof PBImage
|
|
69
|
+
* @type {boolean}
|
|
70
|
+
* @instance
|
|
71
|
+
*/
|
|
72
|
+
isDestroyed: boolean;
|
|
55
73
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
/**
|
|
75
|
+
* The constructor.
|
|
76
|
+
*
|
|
77
|
+
* @constructor
|
|
78
|
+
* @name PBImage
|
|
79
|
+
* @param {Image} image - The actual image.
|
|
80
|
+
* @param {Vertex} upperLeft - The upper left corner.
|
|
81
|
+
* @param {Vertex} lowerRight - The lower right corner.
|
|
82
|
+
**/
|
|
83
|
+
constructor(image: HTMLImageElement, upperLeft: Vertex, lowerRight: Vertex) {
|
|
84
|
+
this.uid = UIDGenerator.next();
|
|
85
|
+
this.image = image;
|
|
86
|
+
this.upperLeft = upperLeft;
|
|
87
|
+
this.lowerRight = lowerRight;
|
|
88
|
+
}
|
|
62
89
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* @param {Vertex} upperLeft - The upper left corner.
|
|
78
|
-
* @param {Vertex} lowerRight - The lower right corner.
|
|
79
|
-
**/
|
|
80
|
-
constructor( image:HTMLImageElement, upperLeft:Vertex, lowerRight:Vertex ) {
|
|
81
|
-
this.uid = UIDGenerator.next();
|
|
82
|
-
this.image = image;
|
|
83
|
-
this.upperLeft = upperLeft;
|
|
84
|
-
this.lowerRight = lowerRight;
|
|
85
|
-
};
|
|
90
|
+
/**
|
|
91
|
+
* Convert this vertex to SVG code.
|
|
92
|
+
*
|
|
93
|
+
* @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
|
|
94
|
+
* @method toSVGString
|
|
95
|
+
* @param {object=} options - An optional set of options, like 'className'.
|
|
96
|
+
* @return {string} A string representing the SVG code for this vertex.
|
|
97
|
+
* @instance
|
|
98
|
+
* @memberof PBImage
|
|
99
|
+
**/
|
|
100
|
+
toSVGString(options: { className?: string }): string {
|
|
101
|
+
console.warn("PBImage is not yet SVG serializable. Returning empty SVG string.");
|
|
102
|
+
return "";
|
|
103
|
+
}
|
|
86
104
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
**/
|
|
98
|
-
toSVGString( options:{ className?:string } ) : string {
|
|
99
|
-
console.warn( "PBImage is not yet SVG serializable. Returning empty SVG string." );
|
|
100
|
-
return "";
|
|
101
|
-
};
|
|
105
|
+
/**
|
|
106
|
+
* This function should invalidate any installed listeners and invalidate this object.
|
|
107
|
+
* After calling this function the object might not hold valid data any more and
|
|
108
|
+
* should not be used.
|
|
109
|
+
*/
|
|
110
|
+
destroy() {
|
|
111
|
+
this.upperLeft.destroy();
|
|
112
|
+
this.lowerRight.destroy();
|
|
113
|
+
this.isDestroyed = true;
|
|
114
|
+
}
|
|
102
115
|
}
|
package/src/ts/PBText.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @author Ikaros Kappler
|
|
3
3
|
* @date 2021-11-16
|
|
4
|
-
* @
|
|
4
|
+
* @modified 2022-02-02 Added the `destroy` method.
|
|
5
|
+
* @version 1.1.0
|
|
5
6
|
**/
|
|
6
7
|
|
|
7
8
|
import { UIDGenerator } from "./UIDGenerator";
|
|
@@ -106,6 +107,14 @@ export class PBText implements SVGSerializable, FontOptions {
|
|
|
106
107
|
*/
|
|
107
108
|
color: string | undefined;
|
|
108
109
|
|
|
110
|
+
/**
|
|
111
|
+
* @member isDestroyed
|
|
112
|
+
* @memberof PBText
|
|
113
|
+
* @type {boolean}
|
|
114
|
+
* @instance
|
|
115
|
+
*/
|
|
116
|
+
isDestroyed: boolean;
|
|
117
|
+
|
|
109
118
|
/**
|
|
110
119
|
* Create a new circle with given center point and radius.
|
|
111
120
|
*
|
|
@@ -144,4 +153,14 @@ export class PBText implements SVGSerializable, FontOptions {
|
|
|
144
153
|
);
|
|
145
154
|
return "";
|
|
146
155
|
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* This function should invalidate any installed listeners and invalidate this object.
|
|
159
|
+
* After calling this function the object might not hold valid data any more and
|
|
160
|
+
* should not be used.
|
|
161
|
+
*/
|
|
162
|
+
destroy() {
|
|
163
|
+
this.anchor.destroy();
|
|
164
|
+
this.isDestroyed = true;
|
|
165
|
+
}
|
|
147
166
|
} // END class
|
|
@@ -897,7 +897,7 @@ export class PlotBoilerplate {
|
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
899
|
for (var i = 0; i < this.drawables.length; i++) {
|
|
900
|
-
if (this.drawables[i] === drawable) {
|
|
900
|
+
if (this.drawables[i] === drawable || this.drawables[i].uid === drawable.uid) {
|
|
901
901
|
this.drawables.splice(i, 1);
|
|
902
902
|
|
|
903
903
|
if (removeWithVertices) {
|
package/src/ts/Polygon.ts
CHANGED
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* @modified 2021-01-29 Changed the param type for `containsVert` from Vertex to XYCoords.
|
|
22
22
|
* @modified 2021-12-14 Added the `perimeter()` function.
|
|
23
23
|
* @modified 2021-12-16 Added the `getEvenDistributionPolygon()` function.
|
|
24
|
-
* @
|
|
24
|
+
* @modified 2022-02-02 Added the `destroy` method.
|
|
25
|
+
* @modified 2022-02-02 Cleared the `Polygon.toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
26
|
+
* @version 1.9.0
|
|
25
27
|
*
|
|
26
28
|
* @file Polygon
|
|
27
29
|
* @public
|
|
@@ -76,6 +78,14 @@ export class Polygon implements SVGSerializable {
|
|
|
76
78
|
*/
|
|
77
79
|
isOpen: boolean;
|
|
78
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @member isDestroyed
|
|
83
|
+
* @memberof Polygon
|
|
84
|
+
* @type {boolean}
|
|
85
|
+
* @instance
|
|
86
|
+
*/
|
|
87
|
+
isDestroyed: boolean;
|
|
88
|
+
|
|
79
89
|
/**
|
|
80
90
|
* The constructor.
|
|
81
91
|
*
|
|
@@ -480,28 +490,44 @@ export class Polygon implements SVGSerializable {
|
|
|
480
490
|
* @memberof Polygon
|
|
481
491
|
**/
|
|
482
492
|
toSVGString(options: { className?: string } | undefined): string {
|
|
483
|
-
options = options || {};
|
|
484
|
-
var buffer: Array<string> = [];
|
|
485
|
-
buffer.push("<path");
|
|
486
|
-
if (options.className) buffer.push(' class="' + options.className + '"');
|
|
487
|
-
buffer.push(' d="');
|
|
488
|
-
if (this.vertices.length > 0) {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
493
|
+
// options = options || {};
|
|
494
|
+
// var buffer: Array<string> = [];
|
|
495
|
+
// buffer.push("<path");
|
|
496
|
+
// if (options.className) buffer.push(' class="' + options.className + '"');
|
|
497
|
+
// buffer.push(' d="');
|
|
498
|
+
// if (this.vertices.length > 0) {
|
|
499
|
+
// buffer.push("M ");
|
|
500
|
+
// buffer.push(this.vertices[0].x.toString());
|
|
501
|
+
// buffer.push(" ");
|
|
502
|
+
// buffer.push(this.vertices[0].y.toString());
|
|
503
|
+
// for (var i = 1; i < this.vertices.length; i++) {
|
|
504
|
+
// buffer.push(" L ");
|
|
505
|
+
// buffer.push(this.vertices[i].x.toString());
|
|
506
|
+
// buffer.push(" ");
|
|
507
|
+
// buffer.push(this.vertices[i].y.toString());
|
|
508
|
+
// }
|
|
509
|
+
// if (!this.isOpen) {
|
|
510
|
+
// buffer.push(" Z");
|
|
511
|
+
// }
|
|
512
|
+
// }
|
|
513
|
+
// buffer.push('" />');
|
|
514
|
+
// return buffer.join("");
|
|
515
|
+
console.warn(
|
|
516
|
+
"[Deprecation] Warning: the Polygon.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead."
|
|
517
|
+
);
|
|
518
|
+
return "";
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* This function should invalidate any installed listeners and invalidate this object.
|
|
523
|
+
* After calling this function the object might not hold valid data any more and
|
|
524
|
+
* should not be used.
|
|
525
|
+
*/
|
|
526
|
+
destroy() {
|
|
527
|
+
for (var i = 0; i < this.vertices.length; i++) {
|
|
528
|
+
this.vertices[i].destroy();
|
|
502
529
|
}
|
|
503
|
-
|
|
504
|
-
return buffer.join("");
|
|
530
|
+
this.isDestroyed = true;
|
|
505
531
|
}
|
|
506
532
|
|
|
507
533
|
static utils = {
|