plotboilerplate 1.20.1 → 1.21.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 (141) hide show
  1. package/README.md +17 -1
  2. package/dist/index.esm.js +2065 -1397
  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 +1265 -584
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +2 -1
  11. package/src/cjs/BezierPath.d.ts +27 -49
  12. package/src/cjs/BezierPath.js +69 -237
  13. package/src/cjs/BezierPath.js.map +1 -1
  14. package/src/cjs/Bounds.d.ts +14 -1
  15. package/src/cjs/Bounds.js +21 -1
  16. package/src/cjs/Bounds.js.map +1 -1
  17. package/src/cjs/CubicBezierCurve.d.ts +70 -1
  18. package/src/cjs/CubicBezierCurve.js +130 -12
  19. package/src/cjs/CubicBezierCurve.js.map +1 -1
  20. package/src/cjs/Line.d.ts +2 -1
  21. package/src/cjs/Line.js +1 -0
  22. package/src/cjs/Line.js.map +1 -1
  23. package/src/cjs/PBText.d.ts +2 -1
  24. package/src/cjs/PBText.js +10 -9
  25. package/src/cjs/PBText.js.map +1 -1
  26. package/src/cjs/PlotBoilerplate.d.ts +10 -13
  27. package/src/cjs/PlotBoilerplate.js +136 -47
  28. package/src/cjs/PlotBoilerplate.js.map +1 -1
  29. package/src/cjs/Polygon.d.ts +35 -1
  30. package/src/cjs/Polygon.js +87 -1
  31. package/src/cjs/Polygon.js.map +1 -1
  32. package/src/cjs/Triangle.js +1 -0
  33. package/src/cjs/Triangle.js.map +1 -1
  34. package/src/cjs/VEllipse.js +1 -1
  35. package/src/cjs/VEllipse.js.map +1 -1
  36. package/src/cjs/Vector.d.ts +4 -4
  37. package/src/cjs/Vector.js +2 -2
  38. package/src/cjs/Vector.js.map +1 -1
  39. package/src/cjs/VertTuple.d.ts +2 -1
  40. package/src/cjs/VertTuple.js +4 -3
  41. package/src/cjs/VertTuple.js.map +1 -1
  42. package/src/cjs/Vertex.d.ts +14 -3
  43. package/src/cjs/Vertex.js +18 -3
  44. package/src/cjs/Vertex.js.map +1 -1
  45. package/src/cjs/draw.d.ts +159 -79
  46. package/src/cjs/draw.js +311 -139
  47. package/src/cjs/draw.js.map +1 -1
  48. package/src/cjs/drawgl.d.ts +93 -55
  49. package/src/cjs/drawgl.js +90 -34
  50. package/src/cjs/drawgl.js.map +1 -1
  51. package/src/cjs/drawutilssvg.d.ts +233 -58
  52. package/src/cjs/drawutilssvg.js +384 -95
  53. package/src/cjs/drawutilssvg.js.map +1 -1
  54. package/src/cjs/interfaces/DrawLib.d.ts +161 -82
  55. package/src/cjs/interfaces/DrawLib.js +7 -0
  56. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  57. package/src/cjs/interfaces/core.d.ts +46 -32
  58. package/src/cjs/interfaces/core.js +2 -0
  59. package/src/cjs/interfaces/core.js.map +1 -1
  60. package/src/cjs/utils/creategui.js +16 -10
  61. package/src/cjs/utils/datastructures/Color.d.ts +3 -1
  62. package/src/cjs/utils/datastructures/Color.js +12 -1
  63. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  64. package/src/cjs/utils/detectDarkMode.d.ts +10 -0
  65. package/src/cjs/utils/detectDarkMode.js +32 -0
  66. package/src/cjs/utils/detectDarkMode.js.map +1 -0
  67. package/src/cjs/utils/module.js +4 -2
  68. package/src/esm/BezierPath.d.ts +27 -49
  69. package/src/esm/BezierPath.js +69 -237
  70. package/src/esm/BezierPath.js.map +1 -1
  71. package/src/esm/Bounds.d.ts +14 -1
  72. package/src/esm/Bounds.js +19 -1
  73. package/src/esm/Bounds.js.map +1 -1
  74. package/src/esm/CubicBezierCurve.d.ts +70 -1
  75. package/src/esm/CubicBezierCurve.js +130 -12
  76. package/src/esm/CubicBezierCurve.js.map +1 -1
  77. package/src/esm/Line.d.ts +2 -1
  78. package/src/esm/Line.js +1 -0
  79. package/src/esm/Line.js.map +1 -1
  80. package/src/esm/PBText.d.ts +2 -1
  81. package/src/esm/PBText.js +10 -9
  82. package/src/esm/PBText.js.map +1 -1
  83. package/src/esm/PlotBoilerplate.d.ts +10 -13
  84. package/src/esm/PlotBoilerplate.js +136 -48
  85. package/src/esm/PlotBoilerplate.js.map +1 -1
  86. package/src/esm/Polygon.d.ts +35 -1
  87. package/src/esm/Polygon.js +85 -1
  88. package/src/esm/Polygon.js.map +1 -1
  89. package/src/esm/Triangle.js +1 -0
  90. package/src/esm/Triangle.js.map +1 -1
  91. package/src/esm/VEllipse.js +1 -1
  92. package/src/esm/VEllipse.js.map +1 -1
  93. package/src/esm/Vector.d.ts +4 -4
  94. package/src/esm/Vector.js +2 -2
  95. package/src/esm/Vector.js.map +1 -1
  96. package/src/esm/VertTuple.d.ts +2 -1
  97. package/src/esm/VertTuple.js +4 -3
  98. package/src/esm/VertTuple.js.map +1 -1
  99. package/src/esm/Vertex.d.ts +14 -3
  100. package/src/esm/Vertex.js +18 -3
  101. package/src/esm/Vertex.js.map +1 -1
  102. package/src/esm/draw.d.ts +159 -79
  103. package/src/esm/draw.js +307 -137
  104. package/src/esm/draw.js.map +1 -1
  105. package/src/esm/drawgl.d.ts +93 -55
  106. package/src/esm/drawgl.js +90 -34
  107. package/src/esm/drawgl.js.map +1 -1
  108. package/src/esm/drawutilssvg.d.ts +233 -58
  109. package/src/esm/drawutilssvg.js +379 -95
  110. package/src/esm/drawutilssvg.js.map +1 -1
  111. package/src/esm/interfaces/DrawLib.d.ts +161 -82
  112. package/src/esm/interfaces/DrawLib.js +7 -0
  113. package/src/esm/interfaces/DrawLib.js.map +1 -1
  114. package/src/esm/interfaces/core.d.ts +46 -32
  115. package/src/esm/interfaces/core.js +2 -0
  116. package/src/esm/interfaces/core.js.map +1 -1
  117. package/src/esm/utils/datastructures/Color.d.ts +3 -1
  118. package/src/esm/utils/datastructures/Color.js +12 -1
  119. package/src/esm/utils/datastructures/Color.js.map +1 -1
  120. package/src/esm/utils/detectDarkMode.d.ts +10 -0
  121. package/src/esm/utils/detectDarkMode.js +28 -0
  122. package/src/esm/utils/detectDarkMode.js.map +1 -0
  123. package/src/ts/BezierPath.ts +74 -244
  124. package/src/ts/Bounds.ts +25 -1
  125. package/src/ts/CubicBezierCurve.ts +139 -12
  126. package/src/ts/Line.ts +2 -1
  127. package/src/ts/PBText.ts +10 -9
  128. package/src/ts/PlotBoilerplate.ts +130 -50
  129. package/src/ts/Polygon.ts +91 -1
  130. package/src/ts/Triangle.ts +2 -1
  131. package/src/ts/VEllipse.ts +2 -2
  132. package/src/ts/Vector.ts +4 -4
  133. package/src/ts/VertTuple.ts +4 -3
  134. package/src/ts/Vertex.ts +20 -4
  135. package/src/ts/draw.ts +316 -119
  136. package/src/ts/drawgl.ts +141 -78
  137. package/src/ts/drawutilssvg.ts +562 -133
  138. package/src/ts/interfaces/DrawLib.ts +223 -86
  139. package/src/ts/interfaces/core.ts +47 -32
  140. package/src/ts/utils/datastructures/Color.ts +13 -1
  141. package/src/ts/utils/detectDarkMode.ts +30 -0
@@ -18,6 +18,13 @@
18
18
  * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.
19
19
  * @modified 2022-02-03 Added the `cross(...)` function.
20
20
  * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
21
+ * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.
22
+ * @modified 2023-09-29 Downgrading all `Vertex` param type to the more generic `XYCoords` type in these render functions: line, arrow, texturedPoly, cubicBezier, cubicBezierPath, handle, handleLine, dot, point, circle, circleArc, ellipse, grid, raster.
23
+ * @modified 2023-09-29 Added the `headLength` parameter to the 'DrawLib.arrow()` function.
24
+ * @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface.
25
+ * @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
26
+ * @modified 2023-09-29 Added the `lineDashes` attribute.
27
+ * @modified 2023-09-30 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
21
28
  **/
22
29
 
23
30
  import { Bounds } from "../Bounds";
@@ -49,6 +56,20 @@ export interface FontOptions {
49
56
  rotation?: number;
50
57
  }
51
58
 
59
+ /**
60
+ * Defines a line-dash configuration.
61
+ *
62
+ * See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
63
+ * and https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
64
+ * for how line dashes work.
65
+ *
66
+ * Setting line-dash to empty array `[]` resets the dashing.
67
+ */
68
+ export interface StrokeOptions {
69
+ dashOffset?: number;
70
+ dashArray?: Array<number>;
71
+ }
72
+
52
73
  /**
53
74
  * An interface all drawing libraries must implement to be used with PlotBoilerplate.
54
75
  *
@@ -71,6 +92,21 @@ export interface DrawLib<R> {
71
92
  */
72
93
  setConfiguration: (configuration: DrawLibConfiguration) => void;
73
94
 
95
+ // /**
96
+ // * Set or clear the line-dash configuration. Pass `null` for un-dashed lines.
97
+ // *
98
+ // * See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
99
+ // * and https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
100
+ // * for how line dashes work.
101
+ // *
102
+ // * Setting line-dash to empty array `[]` resets the dashing.
103
+ // *
104
+ // * @method
105
+ // * @param {Array<number> lineDashes - The line-dash array configuration.
106
+ // * @returns {void}
107
+ // */
108
+ // setLineDash: (lineDashes: Array<number>) => void;
109
+
74
110
  /**
75
111
  * This method shouled be called each time the currently drawn `Drawable` changes.
76
112
  * It is used by some libraries for identifying elemente on re-renders.
@@ -79,7 +115,7 @@ export interface DrawLib<R> {
79
115
  * @method
80
116
  * @param {UID|null} uid - A UID identifying the currently drawn element(s), or null to clear.
81
117
  **/
82
- setCurrentId: (uid: UID | undefined) => void;
118
+ setCurrentId: (uid: UID | null) => void;
83
119
 
84
120
  /**
85
121
  * This method shouled be called each time the currently drawn `Drawable` changes.
@@ -87,9 +123,9 @@ export interface DrawLib<R> {
87
123
  *
88
124
  * @name setCurrentClassName
89
125
  * @method
90
- * @param {string} className - A class name for further custom use cases.
126
+ * @param {string|null} className - A class name for further custom use cases.
91
127
  **/
92
- setCurrentClassName: (className: string | undefined) => void;
128
+ setCurrentClassName: (className: string | null) => void;
93
129
 
94
130
  /**
95
131
  * Called before each draw cycle.
@@ -119,29 +155,84 @@ export interface DrawLib<R> {
119
155
  * Draw the line between the given two points with the specified (CSS-) color.
120
156
  *
121
157
  * @method line
122
- * @param {Vertex} zA - The start point of the line.
123
- * @param {Vertex} zB - The end point of the line.
158
+ * @param {XYCoords} zA - The start point of the line.
159
+ * @param {XYCoords} zB - The end point of the line.
124
160
  * @param {string} color - Any valid CSS color string.
125
- * @param {number=1} lineWidth? - [optional] The line's width.
126
- * @return {void}
161
+ * @param {number=1} lineWidth? - (optional) The line's width.
162
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
163
+ * @return {R}
127
164
  * @instance
128
165
  * @memberof DrawLib
129
166
  **/
130
- line: (zA: Vertex, zB: Vertex, color: string, lineWidth?: number) => R;
167
+ line: (zA: XYCoords, zB: XYCoords, color: string, lineWidth?: number, strokeOptopns?: StrokeOptions) => R;
131
168
 
132
169
  /**
133
- * Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.
170
+ * Draw a line and an arrow at the end (zB) of the given line width the specified (CSS-) color and size.
134
171
  *
135
172
  * @method arrow
136
- * @param {Vertex} zA - The start point of the arrow-line.
137
- * @param {Vertex} zB - The end point of the arrow-line.
173
+ * @param {XYCoords} zA - The start point of the arrow-line.
174
+ * @param {XYCoords} zB - The end point of the arrow-line.
138
175
  * @param {string} color - Any valid CSS color string.
139
- * @param {number=} lineWidth - (optional) The line width to use; default is 1.
140
- * @return {void}
176
+ * @param {number=1} lineWidth - (optional) The line width to use; default is 1.
177
+ * @param {headLength=8} headLength - (optional) The length of the arrow head (default is 8 units).
178
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
179
+ * @return {R}
141
180
  * @instance
142
181
  * @memberof DrawLib
143
182
  **/
144
- arrow: (zA: Vertex, zB: Vertex, color: string, lineWidth?: number) => R;
183
+ arrow: (zA: XYCoords, zB: XYCoords, color: string, lineWidth?: number, headLength?: number, strokeOptopns?: StrokeOptions) => R;
184
+
185
+ /**
186
+ * Draw a cubic Bézier curve and and an arrow at the end (endControlPoint) of the given line width the specified (CSS-) color and arrow size.
187
+ *
188
+ * @method cubicBezierArrow
189
+ * @param {XYCoords} startPoint - The start point of the cubic Bézier curve
190
+ * @param {XYCoords} endPoint - The end point the cubic Bézier curve.
191
+ * @param {XYCoords} startControlPoint - The start control point the cubic Bézier curve.
192
+ * @param {XYCoords} endControlPoint - The end control point the cubic Bézier curve.
193
+ * @param {string} color - The CSS color to draw the curve with.
194
+ * @param {number} lineWidth - (optional) The line width to use.
195
+ * @param {headLength=8} headLength - (optional) The length of the arrow head (default is 8 units).
196
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
197
+ *
198
+ * @return {R}
199
+ * @instance
200
+ * @memberof DrawLib
201
+ */
202
+ cubicBezierArrow: (
203
+ startPoint: XYCoords,
204
+ endPoint: XYCoords,
205
+ startControlPoint: XYCoords,
206
+ endControlPoint: XYCoords,
207
+ color: string,
208
+ lineWidth?: number,
209
+ headLength?: number,
210
+ strokeOptopns?: StrokeOptions
211
+ ) => R;
212
+
213
+ /**
214
+ * Draw just an arrow head a the end of an imaginary line (zB) of the given line width the specified (CSS-) color and size.
215
+ *
216
+ * @method arrow
217
+ * @param {XYCoords} zA - The start point of the arrow-line.
218
+ * @param {XYCoords} zB - The end point of the arrow-line.
219
+ * @param {string} color - Any valid CSS color string.
220
+ * @param {number=1} lineWidth - (optional) The line width to use; default is 1.
221
+ * @param {number=8} headLength - (optional) The length of the arrow head (default is 8 pixels).
222
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
223
+ *
224
+ * @return {R}
225
+ * @instance
226
+ * @memberof DrawLib
227
+ **/
228
+ arrowHead: (
229
+ zA: XYCoords,
230
+ zB: XYCoords,
231
+ color: string,
232
+ lineWidth?: number,
233
+ headLength?: number,
234
+ strokeOptopns?: StrokeOptions
235
+ ) => R;
145
236
 
146
237
  /**
147
238
  * Draw an image at the given position with the given size.<br>
@@ -150,14 +241,14 @@ export interface DrawLib<R> {
150
241
  *
151
242
  * @method image
152
243
  * @param {Image} image - The image object to draw.
153
- * @param {Vertex} position - The position to draw the the upper left corner at.
154
- * @param {Vertex} size - The x/y-size to draw the image with.
244
+ * @param {XYCoords} position - The position to draw the the upper left corner at.
245
+ * @param {XYCoords} size - The x/y-size to draw the image with.
155
246
  * @param {number=1.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).
156
- * @return {void}
247
+ * @return {R}
157
248
  * @instance
158
249
  * @memberof DrawLib
159
250
  **/
160
- image: (image: HTMLImageElement, position: Vertex, size: Vertex, alpha?: number) => R;
251
+ image: (image: HTMLImageElement, position: XYCoords, size: XYCoords, alpha?: number) => R;
161
252
 
162
253
  /**
163
254
  * Draw an image at the given position with the given size.<br>
@@ -168,7 +259,7 @@ export interface DrawLib<R> {
168
259
  * @param {Image} textureImage - The image object to draw.
169
260
  * @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.
170
261
  * @param {Polygon} polygon - The polygon to use as clip path.
171
- * @param {Vertex} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
262
+ * @param {XYCoords} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
172
263
  * @param {number} rotation - The rotation to use for the polygon (and for the texture).
173
264
  * @return {void}
174
265
  * @instance
@@ -178,7 +269,7 @@ export interface DrawLib<R> {
178
269
  textureImage: HTMLImageElement,
179
270
  textureSize: Bounds,
180
271
  polygon: Polygon,
181
- polygonPosition: Vertex,
272
+ polygonPosition: XYCoords,
182
273
  rotation: number
183
274
  ) => R;
184
275
 
@@ -186,23 +277,26 @@ export interface DrawLib<R> {
186
277
  * Draw the given (cubic) bézier curve.
187
278
  *
188
279
  * @method cubicBezier
189
- * @param {Vertex} startPoint - The start point of the cubic Bézier curve
190
- * @param {Vertex} endPoint - The end point the cubic Bézier curve.
191
- * @param {Vertex} startControlPoint - The start control point the cubic Bézier curve.
192
- * @param {Vertex} endControlPoint - The end control point the cubic Bézier curve.
280
+ * @param {XYCoords} startPoint - The start point of the cubic Bézier curve
281
+ * @param {XYCoords} endPoint - The end point the cubic Bézier curve.
282
+ * @param {XYCoords} startControlPoint - The start control point the cubic Bézier curve.
283
+ * @param {XYCoords} endControlPoint - The end control point the cubic Bézier curve.
193
284
  * @param {string} color - The CSS color to draw the curve with.
194
285
  * @param {number} lineWidth - (optional) The line width to use.
195
- * @return {void}
286
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
287
+ *
288
+ * @return {R}
196
289
  * @instance
197
290
  * @memberof DrawLib
198
291
  */
199
292
  cubicBezier: (
200
- startPoint: Vertex,
201
- endPoint: Vertex,
202
- startControlPoint: Vertex,
203
- endControlPoint: Vertex,
293
+ startPoint: XYCoords,
294
+ endPoint: XYCoords,
295
+ startControlPoint: XYCoords,
296
+ endControlPoint: XYCoords,
204
297
  color: string,
205
- lineWidth?: number
298
+ lineWidth?: number,
299
+ strokeOptopns?: StrokeOptions
206
300
  ) => R;
207
301
 
208
302
  /**
@@ -213,14 +307,16 @@ export interface DrawLib<R> {
213
307
  * <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>
214
308
  *
215
309
  * @method cubicBezierPath
216
- * @param {Vertex[]} path - The cubic bezier path as described above.
310
+ * @param {XYCoords[]} path - The cubic bezier path as described above.
217
311
  * @param {string} color - The CSS colot to draw the path with.
218
312
  * @param {number=1} lineWidth - (optional) The line width to use.
219
- * @return {void}
313
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
314
+ *
315
+ * @return {R}
220
316
  * @instance
221
317
  * @memberof DrawLib
222
318
  */
223
- cubicBezierPath: (path: Array<Vertex>, color: string, lineWidth?: number) => R;
319
+ cubicBezierPath: (path: Array<XYCoords>, color: string, lineWidth?: number, strokeOptopns?: StrokeOptions) => R;
224
320
 
225
321
  /**
226
322
  * Draw the given handle and handle point (used to draw interactive Bézier curves).
@@ -228,49 +324,49 @@ export interface DrawLib<R> {
228
324
  * The colors for this are fixed and cannot be specified.
229
325
  *
230
326
  * @method handle
231
- * @param {Vertex} startPoint - The start of the handle.
232
- * @param {Vertex} endPoint - The end point of the handle.
233
- * @return {void}
327
+ * @param {XYCoords} startPoint - The start of the handle.
328
+ * @param {XYCoords} endPoint - The end point of the handle.
329
+ * @return {R}
234
330
  * @instance
235
331
  * @memberof DrawLib
236
332
  */
237
- handle: (startPoint: Vertex, endPoint: Vertex) => R;
333
+ handle: (startPoint: XYCoords, endPoint: XYCoords) => R;
238
334
 
239
335
  /**
240
336
  * Draw a handle line (with a light grey).
241
337
  *
242
338
  * @method handleLine
243
- * @param {Vertex} startPoint - The start point to draw the handle at.
244
- * @param {Vertex} endPoint - The end point to draw the handle at.
245
- * @return {void}
339
+ * @param {XYCoords} startPoint - The start point to draw the handle at.
340
+ * @param {XYCoords} endPoint - The end point to draw the handle at.
341
+ * @return {R}
246
342
  * @instance
247
343
  * @memberof DrawLib
248
344
  */
249
- handleLine: (startPoint: Vertex, endPoint: Vertex) => R;
345
+ handleLine: (startPoint: XYCoords, endPoint: XYCoords) => R;
250
346
 
251
347
  /**
252
348
  * Draw a 1x1 dot with the specified (CSS-) color.
253
349
  *
254
350
  * @method dot
255
- * @param {Vertex} p - The position to draw the dot at.
351
+ * @param {XYCoords} p - The position to draw the dot at.
256
352
  * @param {string} color - The CSS color to draw the dot with.
257
- * @return {void}
353
+ * @return {R}
258
354
  * @instance
259
355
  * @memberof DrawLib
260
356
  */
261
- dot: (p: Vertex, color: string) => R;
357
+ dot: (p: XYCoords, color: string) => R;
262
358
 
263
359
  /**
264
360
  * Draw the given point with the specified (CSS-) color and radius 3.
265
361
  *
266
362
  * @method point
267
- * @param {Vertex} p - The position to draw the point at.
268
- * @param {string} color - The CSS color to draw the point with.
269
- * @return {void}
363
+ * @param {XYCoords} p - The position to draw the point at.
364
+ * @param {XYCoords} color - The CSS color to draw the point with.
365
+ * @return {R}
270
366
  * @instance
271
367
  * @memberof DrawLib
272
368
  */
273
- point: (p: Vertex, color: string) => R;
369
+ point: (p: XYCoords, color: string) => R;
274
370
 
275
371
  /**
276
372
  * Draw a circle with the specified (CSS-) color and radius.<br>
@@ -278,47 +374,69 @@ export interface DrawLib<R> {
278
374
  * Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.
279
375
  *
280
376
  * @method circle
281
- * @param {Vertex} center - The center of the circle.
377
+ * @param {XYCoords} center - The center of the circle.
282
378
  * @param {number} radius - The radius of the circle.
283
379
  * @param {string} color - The CSS color to draw the circle with.
284
380
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
285
- * @return {void}
381
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
382
+ *
383
+ * @return {R}
286
384
  * @instance
287
385
  * @memberof DrawLib
288
386
  */
289
- circle: (center: Vertex, radius: number, color: string, lineWidth?: number) => R;
387
+ circle: (center: XYCoords, radius: number, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
290
388
 
291
389
  /**
292
390
  * Draw a circular arc (section of a circle) with the given CSS color.
293
391
  *
294
392
  * @method circleArc
295
- * @param {Vertex} center - The center of the circle.
393
+ * @param {XYCoords} center - The center of the circle.
296
394
  * @param {number} radius - The radius of the circle.
297
395
  * @param {number} startAngle - The angle to start at.
298
396
  * @param {number} endAngle - The angle to end at.
299
397
  * @param {string} color - The CSS color to draw the circle with.
300
398
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
301
- * @return {void}
399
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
400
+ *
401
+ * @return {R}
302
402
  * @instance
303
403
  * @memberof DrawLib
304
404
  */
305
- circleArc: (center: Vertex, radius: number, startAngle: number, endAngle: number, color: string, lineWidth?: number) => R;
405
+ circleArc: (
406
+ center: XYCoords,
407
+ radius: number,
408
+ startAngle: number,
409
+ endAngle: number,
410
+ color: string,
411
+ lineWidth?: number,
412
+ strokeOptions?: StrokeOptions
413
+ ) => R;
306
414
 
307
415
  /**
308
416
  * Draw an ellipse with the specified (CSS-) color and thw two radii.
309
417
  *
310
418
  * @method ellipse
311
- * @param {Vertex} center - The center of the ellipse.
419
+ * @param {XYCoords} center - The center of the ellipse.
312
420
  * @param {number} radiusX - The radius of the ellipse.
313
421
  * @param {number} radiusY - The radius of the ellipse.
314
422
  * @param {string} color - The CSS color to draw the ellipse with.
315
423
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
316
424
  * @param {number=} rotation - (optional, default=0) The rotation of the ellipse.
317
- * @return {void}
425
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
426
+ *
427
+ * @return {R}
318
428
  * @instance
319
429
  * @memberof DrawLib
320
430
  */
321
- ellipse: (center: Vertex, radiusX: number, radiusY: number, color: string, lineWidth?: number, rotation?: number) => R;
431
+ ellipse: (
432
+ center: XYCoords,
433
+ radiusX: number,
434
+ radiusY: number,
435
+ color: string,
436
+ lineWidth?: number,
437
+ rotation?: number,
438
+ strokeOptions?: StrokeOptions
439
+ ) => R;
322
440
 
323
441
  /**
324
442
  * Draw square at the given center, size and with the specified (CSS-) color.<br>
@@ -330,11 +448,13 @@ export interface DrawLib<R> {
330
448
  * @param {number} size - The size of the square.
331
449
  * @param {string} color - The CSS color to draw the square with.
332
450
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
333
- * @return {void}
451
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
452
+ *
453
+ * @return {R}
334
454
  * @instance
335
455
  * @memberof DrawLib
336
456
  */
337
- square: (center: XYCoords, size: number, color: string, lineWidth?: number) => R;
457
+ square: (center: XYCoords, size: number, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
338
458
 
339
459
  /**
340
460
  * Draw a rectangle at the given left upper corner, with, height; and with the specified line width and (CSS-) color.<br>
@@ -345,27 +465,36 @@ export interface DrawLib<R> {
345
465
  * @param {number} height - The height of the rectangle.
346
466
  * @param {string} color - The CSS color to draw the rectangle with.
347
467
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
348
- * @return {void}
468
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
469
+ *
470
+ * @return {R}
349
471
  * @instance
350
472
  * @memberof DrawLib
351
473
  */
352
- rect: (upperLeft: XYCoords, width: number, height: number, color: string, lineWidth?: number) => R;
474
+ rect: (
475
+ upperLeft: XYCoords,
476
+ width: number,
477
+ height: number,
478
+ color: string,
479
+ lineWidth?: number,
480
+ strokeOptions?: StrokeOptions
481
+ ) => R;
353
482
 
354
483
  /**
355
484
  * Draw a grid of horizontal and vertical lines with the given (CSS-) color.
356
485
  *
357
486
  * @method grid
358
- * @param {Vertex} center - The center of the grid.
487
+ * @param {XYCoords} center - The center of the grid.
359
488
  * @param {number} width - The total width of the grid (width/2 each to the left and to the right).
360
489
  * @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).
361
490
  * @param {number} sizeX - The horizontal grid size.
362
491
  * @param {number} sizeY - The vertical grid size.
363
492
  * @param {string} color - The CSS color to draw the grid with.
364
- * @return {void}
493
+ * @return {R}
365
494
  * @instance
366
495
  * @memberof DrawLib
367
496
  */
368
- grid: (center: Vertex, width: number, height: number, sizeX: number, sizeY: number, color: string) => R;
497
+ grid: (center: XYCoords, width: number, height: number, sizeX: number, sizeY: number, color: string) => R;
369
498
 
370
499
  /**
371
500
  * Draw a raster of crosshairs in the given grid.<br>
@@ -373,17 +502,17 @@ export interface DrawLib<R> {
373
502
  * This works analogue to the grid() function
374
503
  *
375
504
  * @method raster
376
- * @param {Vertex} center - The center of the raster.
505
+ * @param {XYCoords} center - The center of the raster.
377
506
  * @param {number} width - The total width of the raster (width/2 each to the left and to the right).
378
507
  * @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).
379
508
  * @param {number} sizeX - The horizontal raster size.
380
509
  * @param {number} sizeY - The vertical raster size.
381
510
  * @param {string} color - The CSS color to draw the raster with.
382
- * @return {void}
511
+ * @return {R}
383
512
  * @instance
384
513
  * @memberof DrawLib
385
514
  */
386
- raster: (center: Vertex, width: number, height: number, sizeX: number, sizeY: number, color: string) => R;
515
+ raster: (center: XYCoords, width: number, height: number, sizeX: number, sizeY: number, color: string) => R;
387
516
 
388
517
  /**
389
518
  * Draw a diamond handle (square rotated by 45°) with the given CSS color.
@@ -393,14 +522,14 @@ export interface DrawLib<R> {
393
522
  * as even shaped diamonds.
394
523
  *
395
524
  * @method diamondHandle
396
- * @param {Vertex} center - The center of the diamond.
397
- * @param {Vertex} size - The x/y-size of the diamond.
525
+ * @param {XYCoords} center - The center of the diamond.
526
+ * @param {number} size - The x/y-size of the diamond.
398
527
  * @param {string} color - The CSS color to draw the diamond with.
399
- * @return {void}
528
+ * @return {R}
400
529
  * @instance
401
530
  * @memberof DrawLib
402
531
  */
403
- diamondHandle: (center: Vertex, size: number, color: string) => R;
532
+ diamondHandle: (center: XYCoords, size: number, color: string) => R;
404
533
 
405
534
  /**
406
535
  * Draw a square handle with the given CSS color.<br>
@@ -410,14 +539,14 @@ export interface DrawLib<R> {
410
539
  * as even shaped squares.
411
540
  *
412
541
  * @method squareHandle
413
- * @param {Vertex} center - The center of the square.
414
- * @param {Vertex} size - The x/y-size of the square.
542
+ * @param {XYCoords} center - The center of the square.
543
+ * @param {number} size - The x/y-size of the square.
415
544
  * @param {string} color - The CSS color to draw the square with.
416
- * @return {void}
545
+ * @return {R}
417
546
  * @instance
418
547
  * @memberof DrawLib
419
548
  */
420
- squareHandle: (center: Vertex, size: number, color: string) => R;
549
+ squareHandle: (center: XYCoords, size: number, color: string) => R;
421
550
 
422
551
  /**
423
552
  * Draw a circle handle with the given CSS color.<br>
@@ -427,14 +556,14 @@ export interface DrawLib<R> {
427
556
  * as even shaped circles.
428
557
  *
429
558
  * @method circleHandle
430
- * @param {Vertex} center - The center of the circle.
559
+ * @param {XYCoords} center - The center of the circle.
431
560
  * @param {number} radius - The radius of the circle.
432
561
  * @param {string} color - The CSS color to draw the circle with.
433
- * @return {void}
562
+ * @return {R}
434
563
  * @instance
435
564
  * @memberof DrawLib
436
565
  */
437
- circleHandle: (center: Vertex, size: number, color: string) => R;
566
+ circleHandle: (center: XYCoords, size: number, color: string) => R;
438
567
 
439
568
  /**
440
569
  * Draw a crosshair with given radius and color at the given position.<br>
@@ -446,7 +575,7 @@ export interface DrawLib<R> {
446
575
  * @param {number} radius - The radius of the crosshair.
447
576
  * @param {string} color - The CSS color to draw the crosshair with.
448
577
  * @param {number=0.5} lineWidth - (optional, default=0.5) The line width to use.
449
- * @return {void}
578
+ * @return {R}
450
579
  * @instance
451
580
  * @memberof DrawLib
452
581
  */
@@ -462,7 +591,7 @@ export interface DrawLib<R> {
462
591
  * @param {number} radius - The radius of the crosshair.
463
592
  * @param {string} color - The CSS color to draw the crosshair with.
464
593
  * @param {number=1} lineWidth - (optional, default=1.0) The line width to use.
465
- * @return {void}
594
+ * @return {R}
466
595
  * @instance
467
596
  * @memberof DrawLib
468
597
  */
@@ -474,25 +603,30 @@ export interface DrawLib<R> {
474
603
  * @method polygon
475
604
  * @param {Polygon} polygon - The polygon to draw.
476
605
  * @param {string} color - The CSS color to draw the polygon with.
477
- * @return {void}
606
+ * @param {number=} lineWidth - The line width to draw this polygon with.
607
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
608
+ *
609
+ * @return {R}
478
610
  * @instance
479
611
  * @memberof DrawLib
480
612
  */
481
- polygon: (polygon: Polygon, color: string, lineWidth?: number) => R;
613
+ polygon: (polygon: Polygon, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
482
614
 
483
615
  /**
484
616
  * Draw a polygon line (alternative function to the polygon).
485
617
  *
486
618
  * @method polyline
487
- * @param {Vertex[]} vertices - The polygon vertices to draw.
619
+ * @param {XYCoords[]} vertices - The polygon vertices to draw.
488
620
  * @param {boolan} isOpen - If true the polyline will not be closed at its end.
489
621
  * @param {string} color - The CSS color to draw the polygon with.
490
622
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
491
- * @return {void}
623
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
624
+ *
625
+ * @return {R}
492
626
  * @instance
493
627
  * @memberof DrawLib
494
628
  */
495
- polyline: (vertices: Array<Vertex>, isOpen: boolean, color: string, lineWidth?: number) => R;
629
+ polyline: (vertices: Array<XYCoords>, isOpen: boolean, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
496
630
 
497
631
  /**
498
632
  * Draw a text at the given relative position.
@@ -538,11 +672,14 @@ export interface DrawLib<R> {
538
672
  * @param {string=null} color - (optional) The color to draw this path with (default is null).
539
673
  * @param {number=1} lineWidth - (optional) the line width to use (default is 1).
540
674
  * @param {boolean=false} options.inplace - (optional) If set to true then path transforamtions (scale and translate) will be done in-place in the array. This can boost the performance.
675
+ * @param {number=} options.dashOffset - See `StrokeOptions`.
676
+ * @param {number[]=} options.dashArray - See `StrokeOptions`.
677
+ *
541
678
  * @instance
542
679
  * @memberof DrawLib
543
680
  * @return {R} An instance representing the drawn path.
544
681
  */
545
- path: (pathData: SVGPathParams, color?: string, lineWidth?: number, options?: { inplace?: boolean }) => R;
682
+ path: (pathData: SVGPathParams, color?: string, lineWidth?: number, options?: { inplace?: boolean } & StrokeOptions) => R;
546
683
 
547
684
  /**
548
685
  * Due to gl compatibility there is a generic 'clear' function required