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.
Files changed (153) hide show
  1. package/changelog.md +24 -0
  2. package/dist/index.esm.js +574 -428
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +574 -428
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +1 -1
  11. package/src/cjs/BezierPath.d.ts +33 -1
  12. package/src/cjs/BezierPath.js +80 -13
  13. package/src/cjs/BezierPath.js.map +1 -1
  14. package/src/cjs/Circle.d.ts +25 -10
  15. package/src/cjs/Circle.js +38 -33
  16. package/src/cjs/Circle.js.map +1 -1
  17. package/src/cjs/CircleSector.d.ts +27 -13
  18. package/src/cjs/CircleSector.js +38 -23
  19. package/src/cjs/CircleSector.js.map +1 -1
  20. package/src/cjs/CubicBezierCurve.d.ts +17 -1
  21. package/src/cjs/CubicBezierCurve.js +78 -79
  22. package/src/cjs/CubicBezierCurve.js.map +1 -1
  23. package/src/cjs/KeyHandler.d.ts +10 -3
  24. package/src/cjs/KeyHandler.js +28 -23
  25. package/src/cjs/KeyHandler.js.map +1 -1
  26. package/src/cjs/Line.d.ts +2 -1
  27. package/src/cjs/Line.js +19 -18
  28. package/src/cjs/Line.js.map +1 -1
  29. package/src/cjs/MouseHandler.js +43 -53
  30. package/src/cjs/MouseHandler.js.map +1 -1
  31. package/src/cjs/PBImage.d.ts +16 -1
  32. package/src/cjs/PBImage.js +13 -3
  33. package/src/cjs/PBImage.js.map +1 -1
  34. package/src/cjs/PBText.d.ts +15 -1
  35. package/src/cjs/PBText.js +11 -1
  36. package/src/cjs/PBText.js.map +1 -1
  37. package/src/cjs/PlotBoilerplate.js +1 -1
  38. package/src/cjs/PlotBoilerplate.js.map +1 -1
  39. package/src/cjs/Polygon.d.ts +16 -1
  40. package/src/cjs/Polygon.js +37 -23
  41. package/src/cjs/Polygon.js.map +1 -1
  42. package/src/cjs/Triangle.d.ts +16 -1
  43. package/src/cjs/Triangle.js +50 -54
  44. package/src/cjs/Triangle.js.map +1 -1
  45. package/src/cjs/VEllipse.d.ts +16 -1
  46. package/src/cjs/VEllipse.js +25 -12
  47. package/src/cjs/VEllipse.js.map +1 -1
  48. package/src/cjs/VEllipseSector.d.ts +15 -1
  49. package/src/cjs/VEllipseSector.js +11 -1
  50. package/src/cjs/VEllipseSector.js.map +1 -1
  51. package/src/cjs/Vector.d.ts +3 -1
  52. package/src/cjs/Vector.js +32 -36
  53. package/src/cjs/Vector.js.map +1 -1
  54. package/src/cjs/VertTuple.d.ts +15 -1
  55. package/src/cjs/VertTuple.js +14 -19
  56. package/src/cjs/VertTuple.js.map +1 -1
  57. package/src/cjs/Vertex.d.ts +25 -1
  58. package/src/cjs/Vertex.js +38 -11
  59. package/src/cjs/Vertex.js.map +1 -1
  60. package/src/cjs/VertexListeners.d.ts +12 -8
  61. package/src/cjs/VertexListeners.js +18 -25
  62. package/src/cjs/VertexListeners.js.map +1 -1
  63. package/src/cjs/utils/creategui.js +1 -1
  64. package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +15 -0
  65. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +55 -28
  66. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  67. package/src/cjs/utils/io/DndFileHandler.d.ts +63 -0
  68. package/src/cjs/utils/io/DndFileHandler.js +112 -0
  69. package/src/cjs/utils/io/DndFileHandler.js.map +1 -0
  70. package/src/cjs/utils/io/FileDrop.d.ts +98 -0
  71. package/src/cjs/utils/io/FileDrop.js +142 -0
  72. package/src/cjs/utils/io/FileDrop.js.map +1 -0
  73. package/src/esm/BezierPath.d.ts +33 -1
  74. package/src/esm/BezierPath.js +80 -13
  75. package/src/esm/BezierPath.js.map +1 -1
  76. package/src/esm/Circle.d.ts +25 -10
  77. package/src/esm/Circle.js +38 -33
  78. package/src/esm/Circle.js.map +1 -1
  79. package/src/esm/CircleSector.d.ts +27 -13
  80. package/src/esm/CircleSector.js +38 -23
  81. package/src/esm/CircleSector.js.map +1 -1
  82. package/src/esm/CubicBezierCurve.d.ts +17 -1
  83. package/src/esm/CubicBezierCurve.js +78 -79
  84. package/src/esm/CubicBezierCurve.js.map +1 -1
  85. package/src/esm/KeyHandler.d.ts +10 -3
  86. package/src/esm/KeyHandler.js +28 -23
  87. package/src/esm/KeyHandler.js.map +1 -1
  88. package/src/esm/Line.d.ts +2 -1
  89. package/src/esm/Line.js +19 -18
  90. package/src/esm/Line.js.map +1 -1
  91. package/src/esm/MouseHandler.js +43 -53
  92. package/src/esm/MouseHandler.js.map +1 -1
  93. package/src/esm/PBImage.d.ts +16 -1
  94. package/src/esm/PBImage.js +13 -3
  95. package/src/esm/PBImage.js.map +1 -1
  96. package/src/esm/PBText.d.ts +15 -1
  97. package/src/esm/PBText.js +11 -1
  98. package/src/esm/PBText.js.map +1 -1
  99. package/src/esm/PlotBoilerplate.js +1 -1
  100. package/src/esm/PlotBoilerplate.js.map +1 -1
  101. package/src/esm/Polygon.d.ts +16 -1
  102. package/src/esm/Polygon.js +37 -23
  103. package/src/esm/Polygon.js.map +1 -1
  104. package/src/esm/Triangle.d.ts +16 -1
  105. package/src/esm/Triangle.js +50 -54
  106. package/src/esm/Triangle.js.map +1 -1
  107. package/src/esm/VEllipse.d.ts +16 -1
  108. package/src/esm/VEllipse.js +25 -12
  109. package/src/esm/VEllipse.js.map +1 -1
  110. package/src/esm/VEllipseSector.d.ts +15 -1
  111. package/src/esm/VEllipseSector.js +11 -1
  112. package/src/esm/VEllipseSector.js.map +1 -1
  113. package/src/esm/Vector.d.ts +3 -1
  114. package/src/esm/Vector.js +32 -36
  115. package/src/esm/Vector.js.map +1 -1
  116. package/src/esm/VertTuple.d.ts +15 -1
  117. package/src/esm/VertTuple.js +14 -19
  118. package/src/esm/VertTuple.js.map +1 -1
  119. package/src/esm/Vertex.d.ts +25 -1
  120. package/src/esm/Vertex.js +38 -11
  121. package/src/esm/Vertex.js.map +1 -1
  122. package/src/esm/VertexListeners.d.ts +12 -8
  123. package/src/esm/VertexListeners.js +18 -25
  124. package/src/esm/VertexListeners.js.map +1 -1
  125. package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +15 -0
  126. package/src/esm/utils/helpers/BezierPathInteractionHelper.js +54 -28
  127. package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  128. package/src/esm/utils/io/DndFileHandler.d.ts +63 -0
  129. package/src/esm/utils/io/DndFileHandler.js +106 -0
  130. package/src/esm/utils/io/DndFileHandler.js.map +1 -0
  131. package/src/esm/utils/io/FileDrop.d.ts +98 -0
  132. package/src/esm/utils/io/FileDrop.js +136 -0
  133. package/src/esm/utils/io/FileDrop.js.map +1 -0
  134. package/src/ts/BezierPath.ts +96 -11
  135. package/src/ts/Circle.ts +213 -200
  136. package/src/ts/CircleSector.ts +171 -141
  137. package/src/ts/CubicBezierCurve.ts +777 -810
  138. package/src/ts/KeyHandler.ts +221 -212
  139. package/src/ts/Line.ts +77 -80
  140. package/src/ts/MouseHandler.ts +356 -368
  141. package/src/ts/PBImage.ts +81 -68
  142. package/src/ts/PBText.ts +20 -1
  143. package/src/ts/PlotBoilerplate.ts +1 -1
  144. package/src/ts/Polygon.ts +48 -22
  145. package/src/ts/Triangle.ts +484 -489
  146. package/src/ts/VEllipse.ts +36 -11
  147. package/src/ts/VEllipseSector.ts +20 -1
  148. package/src/ts/Vector.ts +164 -160
  149. package/src/ts/VertTuple.ts +333 -338
  150. package/src/ts/Vertex.ts +52 -10
  151. package/src/ts/VertexListeners.ts +248 -266
  152. package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +61 -30
  153. package/src/ts/utils/io/FileDrop.ts +178 -0
package/src/ts/Circle.ts CHANGED
@@ -7,10 +7,11 @@
7
7
  * @modified 2020-09-07 Changed the vertAt function by switching sin and cos! The old version did not return the correct vertex (by angle) accoring to the assumed circle math.
8
8
  * @modified 2020-10-16 Added the containsCircle(...) function.
9
9
  * @modified 2021-01-20 Added UID.
10
- * @version 1.2.0
10
+ * @modified 2022-02-02 Added the `destroy` method.
11
+ * @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.
12
+ * @version 1.3.0
11
13
  **/
12
14
 
13
-
14
15
  import { Line } from "./Line";
15
16
  import { UIDGenerator } from "./UIDGenerator";
16
17
  import { Vector } from "./Vector";
@@ -18,214 +19,226 @@ import { VertTuple } from "./VertTuple";
18
19
  import { Vertex } from "./Vertex";
19
20
  import { SVGSerializable, UID } from "./interfaces";
20
21
 
21
-
22
22
  /**
23
23
  * @classdesc A simple circle: center point and radius.
24
24
  *
25
25
  * @requires Line
26
26
  * @requires Vector
27
- * @requires VertTuple
27
+ * @requires VertTuple
28
28
  * @requires Vertex
29
29
  * @requires SVGSerializale
30
30
  * @requires UID
31
31
  * @requires UIDGenerator
32
32
  **/
33
33
  export class Circle implements SVGSerializable {
34
-
35
- /**
36
- * Required to generate proper CSS classes and other class related IDs.
37
- **/
38
- readonly className : string = "Circle";
39
-
40
- /**
41
- * The UID of this drawable object.
42
- *
43
- * @member {UID}
44
- * @memberof Circle
45
- * @instance
46
- * @readonly
47
- */
48
- readonly uid : UID;
49
-
50
-
51
- /**
52
- * @member {Vertex}
53
- * @memberof Circle
54
- * @instance
55
- */
56
- center:Vertex;
57
-
58
- /**
59
- * @member {number}
60
- * @memberof Circle
61
- * @instance
62
- */
63
- radius:number;
64
-
65
-
66
- /**
67
- * Create a new circle with given center point and radius.
68
- *
69
- * @constructor
70
- * @name Circle
71
- * @param {Vertex} center - The center point of the circle.
72
- * @param {number} radius - The radius of the circle.
73
- */
74
- constructor( center:Vertex, radius:number ) {
75
- this.uid = UIDGenerator.next();
76
- this.center = center;
77
- this.radius = radius;
78
- };
79
-
80
-
81
- /**
82
- * Check if the given circle is fully contained inside this circle.
83
- *
84
- * @method containsCircle
85
- * @param {Circle} circle - The circle to check if it is contained in this circle.
86
- * @instance
87
- * @memberof Circle
88
- * @return {boolean} `true` if any only if the given circle is completely inside this circle.
89
- */
90
- containsCircle( circle:Circle ) : boolean {
91
- return this.center.distance(circle.center) + circle.radius < this.radius;
92
- };
93
-
94
-
95
- /**
96
- * Calculate the distance from this circle to the given line.
97
- *
98
- * * If the line does not intersect this ciecle then the returned
99
- * value will be the minimal distance.
100
- * * If the line goes through this circle then the returned value
101
- * will be max inner distance and it will be negative.
102
- *
103
- * @method lineDistance
104
- * @param {Line} line - The line to measure the distance to.
105
- * @return {number} The minimal distance from the outline of this circle to the given line.
106
- * @instance
107
- * @memberof Circle
108
- */
109
- lineDistance( line:VertTuple<any> ) : number {
110
- const closestPointOnLine : Vertex = line.getClosestPoint( this.center );
111
- return closestPointOnLine.distance( this.center ) - this.radius;
112
- };
113
-
114
- /**
115
- * Get the vertex on the this circle for the given angle.
116
- *
117
- * @method vertAt
118
- * @param {number} angle - The angle (in radians) to use.
119
- * @return {Vertex} The vertex (point) at the given angle.
120
- * @instance
121
- * @memberof Circle
122
- **/
123
- vertAt( angle: number ) : Vertex {
124
- // Find the point on the circle respective the angle. Then move relative to center.
125
- return Circle.circleUtils.vertAt( angle, this.radius ).add( this.center );
126
- };
127
-
128
-
129
- /**
130
- * Get a tangent line of this circle for a given angle.
131
- *
132
- * Point a of the returned line is located on the circle, the length equals the radius.
133
- *
134
- * @method tangentAt
135
- * @instance
136
- * @param {number} angle - The angle (in radians) to use.
137
- * @return {Line} The tangent line.
138
- * @memberof Circle
139
- **/
140
- tangentAt( angle: number ) : Vector {
141
- const pointA : Vertex = Circle.circleUtils.vertAt( angle, this.radius );
142
- // Construct the perpendicular of the line in point a. Then move relative to center.
143
- return (new Vector( pointA, new Vertex(0,0) ).add( this.center ) as Vector).perp() as Vector;
144
- };
145
-
146
- /**
147
- * Calculate the intersection points (if exists) with the given circle.
148
- *
149
- * @method circleIntersection
150
- * @instance
151
- * @memberof Circle
152
- * @param {Circle} circle
153
- * @return {Line|null} The intersection points (as a line) or null if the two circles do not intersect.
154
- **/
155
- circleIntersection( circle:Circle ) : Line | null {
156
- // Circles do not intersect at all?
157
- if( this.center.distance(circle.center) > this.radius+circle.radius ) {
158
- return null;
159
- }
160
- // One circle is fully inside the other?
161
- if( this.center.distance(circle.center) < Math.abs(this.radius-circle.radius) ) {
162
- return null;
163
- }
164
- // Based on the C++ implementation by Robert King
165
- // https://stackoverflow.com/questions/3349125/circle-circle-intersection-points
166
- // and the 'Circles and spheres' article by Paul Bourke.
167
- // http://paulbourke.net/geometry/circlesphere/
168
- //
169
- // This is the original C++ implementation:
170
- //
171
- // pair<Point, Point> intersections(Circle c) {
172
- // Point P0(x, y);
173
- // Point P1(c.x, c.y);
174
- // float d, a, h;
175
- // d = P0.distance(P1);
176
- // a = (r*r - c.r*c.r + d*d)/(2*d);
177
- // h = sqrt(r*r - a*a);
178
- // Point P2 = P1.sub(P0).scale(a/d).add(P0);
179
- // float x3, y3, x4, y4;
180
- // x3 = P2.x + h*(P1.y - P0.y)/d;
181
- // y3 = P2.y - h*(P1.x - P0.x)/d;
182
- // x4 = P2.x - h*(P1.y - P0.y)/d;
183
- // y4 = P2.y + h*(P1.x - P0.x)/d;
184
- // return pair<Point, Point>(Point(x3, y3), Point(x4, y4));
185
- // }
186
- var p0 = this.center;
187
- var p1 = circle.center;
188
- var d = p0.distance(p1);
189
- var a = (this.radius*this.radius - circle.radius*circle.radius + d*d)/(2*d);
190
- var h = Math.sqrt( this.radius*this.radius - a*a );
191
- var p2 = p1.clone().scale(a/d,p0);
192
- var x3 = p2.x + h*(p1.y - p0.y)/d;
193
- var y3 = p2.y - h*(p1.x - p0.x)/d;
194
- var x4 = p2.x - h*(p1.y - p0.y)/d;
195
- var y4 = p2.y + h*(p1.x - p0.x)/d;
196
- return new Line( new Vertex(x3,y3), new Vertex(x4,y4) );
197
- };
198
-
199
- /**
200
- * Create an SVG representation of this circle.
201
- *
202
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
203
- * @method toSVGString
204
- * @param {object=} options - An optional set of options, like 'className'.
205
- * @return {string} A string representing the SVG code for this vertex.
206
- * @instance
207
- * @memberof Circle
208
- */
209
- toSVGString( options:{className?:string } ) {
210
- options = options || {};
211
- var buffer : Array<string> = [];
212
- buffer.push( '<circle' );
213
- if( options.className )
214
- buffer.push( ' class="' + options.className + '"' );
215
- buffer.push( ' cx="' + this.center.x + '"' );
216
- buffer.push( ' cy="' + this.center.y + '"' );
217
- buffer.push( ' r="' + this.radius + '"' );
218
- buffer.push( ' />' );
219
- return buffer.join('');
220
- };
221
-
222
- static circleUtils = {
223
- vertAt : (angle:number,radius:number) => {
224
- /* return new Vertex( Math.sin(angle) * radius,
34
+ /**
35
+ * Required to generate proper CSS classes and other class related IDs.
36
+ **/
37
+ readonly className: string = "Circle";
38
+
39
+ /**
40
+ * The UID of this drawable object.
41
+ *
42
+ * @member {UID}
43
+ * @memberof Circle
44
+ * @instance
45
+ * @readonly
46
+ */
47
+ readonly uid: UID;
48
+
49
+ /**
50
+ * @member {Vertex}
51
+ * @memberof Circle
52
+ * @instance
53
+ */
54
+ center: Vertex;
55
+
56
+ /**
57
+ * @member {number}
58
+ * @memberof Circle
59
+ * @instance
60
+ */
61
+ radius: number;
62
+
63
+ /**
64
+ * @member isDestroyed
65
+ * @memberof CubicBezierCurve
66
+ * @type {boolean}
67
+ * @instance
68
+ */
69
+ isDestroyed: boolean;
70
+
71
+ /**
72
+ * Create a new circle with given center point and radius.
73
+ *
74
+ * @constructor
75
+ * @name Circle
76
+ * @param {Vertex} center - The center point of the circle.
77
+ * @param {number} radius - The radius of the circle.
78
+ */
79
+ constructor(center: Vertex, radius: number) {
80
+ this.uid = UIDGenerator.next();
81
+ this.center = center;
82
+ this.radius = radius;
83
+ }
84
+
85
+ /**
86
+ * Check if the given circle is fully contained inside this circle.
87
+ *
88
+ * @method containsCircle
89
+ * @param {Circle} circle - The circle to check if it is contained in this circle.
90
+ * @instance
91
+ * @memberof Circle
92
+ * @return {boolean} `true` if any only if the given circle is completely inside this circle.
93
+ */
94
+ containsCircle(circle: Circle): boolean {
95
+ return this.center.distance(circle.center) + circle.radius < this.radius;
96
+ }
97
+
98
+ /**
99
+ * Calculate the distance from this circle to the given line.
100
+ *
101
+ * * If the line does not intersect this ciecle then the returned
102
+ * value will be the minimal distance.
103
+ * * If the line goes through this circle then the returned value
104
+ * will be max inner distance and it will be negative.
105
+ *
106
+ * @method lineDistance
107
+ * @param {Line} line - The line to measure the distance to.
108
+ * @return {number} The minimal distance from the outline of this circle to the given line.
109
+ * @instance
110
+ * @memberof Circle
111
+ */
112
+ lineDistance(line: VertTuple<any>): number {
113
+ const closestPointOnLine: Vertex = line.getClosestPoint(this.center);
114
+ return closestPointOnLine.distance(this.center) - this.radius;
115
+ }
116
+
117
+ /**
118
+ * Get the vertex on the this circle for the given angle.
119
+ *
120
+ * @method vertAt
121
+ * @param {number} angle - The angle (in radians) to use.
122
+ * @return {Vertex} The vertex (point) at the given angle.
123
+ * @instance
124
+ * @memberof Circle
125
+ **/
126
+ vertAt(angle: number): Vertex {
127
+ // Find the point on the circle respective the angle. Then move relative to center.
128
+ return Circle.circleUtils.vertAt(angle, this.radius).add(this.center);
129
+ }
130
+
131
+ /**
132
+ * Get a tangent line of this circle for a given angle.
133
+ *
134
+ * Point a of the returned line is located on the circle, the length equals the radius.
135
+ *
136
+ * @method tangentAt
137
+ * @instance
138
+ * @param {number} angle - The angle (in radians) to use.
139
+ * @return {Line} The tangent line.
140
+ * @memberof Circle
141
+ **/
142
+ tangentAt(angle: number): Vector {
143
+ const pointA: Vertex = Circle.circleUtils.vertAt(angle, this.radius);
144
+ // Construct the perpendicular of the line in point a. Then move relative to center.
145
+ return (new Vector(pointA, new Vertex(0, 0)).add(this.center) as Vector).perp() as Vector;
146
+ }
147
+
148
+ /**
149
+ * Calculate the intersection points (if exists) with the given circle.
150
+ *
151
+ * @method circleIntersection
152
+ * @instance
153
+ * @memberof Circle
154
+ * @param {Circle} circle
155
+ * @return {Line|null} The intersection points (as a line) or null if the two circles do not intersect.
156
+ **/
157
+ circleIntersection(circle: Circle): Line | null {
158
+ // Circles do not intersect at all?
159
+ if (this.center.distance(circle.center) > this.radius + circle.radius) {
160
+ return null;
161
+ }
162
+ // One circle is fully inside the other?
163
+ if (this.center.distance(circle.center) < Math.abs(this.radius - circle.radius)) {
164
+ return null;
165
+ }
166
+ // Based on the C++ implementation by Robert King
167
+ // https://stackoverflow.com/questions/3349125/circle-circle-intersection-points
168
+ // and the 'Circles and spheres' article by Paul Bourke.
169
+ // http://paulbourke.net/geometry/circlesphere/
170
+ //
171
+ // This is the original C++ implementation:
172
+ //
173
+ // pair<Point, Point> intersections(Circle c) {
174
+ // Point P0(x, y);
175
+ // Point P1(c.x, c.y);
176
+ // float d, a, h;
177
+ // d = P0.distance(P1);
178
+ // a = (r*r - c.r*c.r + d*d)/(2*d);
179
+ // h = sqrt(r*r - a*a);
180
+ // Point P2 = P1.sub(P0).scale(a/d).add(P0);
181
+ // float x3, y3, x4, y4;
182
+ // x3 = P2.x + h*(P1.y - P0.y)/d;
183
+ // y3 = P2.y - h*(P1.x - P0.x)/d;
184
+ // x4 = P2.x - h*(P1.y - P0.y)/d;
185
+ // y4 = P2.y + h*(P1.x - P0.x)/d;
186
+ // return pair<Point, Point>(Point(x3, y3), Point(x4, y4));
187
+ // }
188
+ var p0 = this.center;
189
+ var p1 = circle.center;
190
+ var d = p0.distance(p1);
191
+ var a = (this.radius * this.radius - circle.radius * circle.radius + d * d) / (2 * d);
192
+ var h = Math.sqrt(this.radius * this.radius - a * a);
193
+ var p2 = p1.clone().scale(a / d, p0);
194
+ var x3 = p2.x + (h * (p1.y - p0.y)) / d;
195
+ var y3 = p2.y - (h * (p1.x - p0.x)) / d;
196
+ var x4 = p2.x - (h * (p1.y - p0.y)) / d;
197
+ var y4 = p2.y + (h * (p1.x - p0.x)) / d;
198
+ return new Line(new Vertex(x3, y3), new Vertex(x4, y4));
199
+ }
200
+
201
+ /**
202
+ * Create an SVG representation of this circle.
203
+ *
204
+ * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
205
+ * @method toSVGString
206
+ * @param {object=} options - An optional set of options, like 'className'.
207
+ * @return {string} A string representing the SVG code for this vertex.
208
+ * @instance
209
+ * @memberof Circle
210
+ */
211
+ toSVGString(options: { className?: string }) {
212
+ // options = options || {};
213
+ // var buffer: Array<string> = [];
214
+ // buffer.push("<circle");
215
+ // if (options.className) buffer.push(' class="' + options.className + '"');
216
+ // buffer.push(' cx="' + this.center.x + '"');
217
+ // buffer.push(' cy="' + this.center.y + '"');
218
+ // buffer.push(' r="' + this.radius + '"');
219
+ // buffer.push(" />");
220
+ // return buffer.join("");
221
+ console.warn(
222
+ "[Deprecation] Warning: the Circle.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead."
223
+ );
224
+ return "";
225
+ }
226
+
227
+ /**
228
+ * This function should invalidate any installed listeners and invalidate this object.
229
+ * After calling this function the object might not hold valid data any more and
230
+ * should not be used.
231
+ */
232
+ destroy() {
233
+ this.center.destroy();
234
+ this.isDestroyed = true;
235
+ }
236
+
237
+ static circleUtils = {
238
+ vertAt: (angle: number, radius: number) => {
239
+ /* return new Vertex( Math.sin(angle) * radius,
225
240
  Math.cos(angle) * radius ); */
226
- return new Vertex( Math.cos(angle) * radius,
227
- Math.sin(angle) * radius );
228
- }
229
- };
230
-
241
+ return new Vertex(Math.cos(angle) * radius, Math.sin(angle) * radius);
242
+ }
243
+ };
231
244
  } // END class