plotboilerplate 1.20.2 → 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.
- package/dist/index.esm.js +1985 -1368
- 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 +1170 -541
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/BezierPath.d.ts +27 -49
- package/src/cjs/BezierPath.js +67 -234
- package/src/cjs/BezierPath.js.map +1 -1
- package/src/cjs/Bounds.d.ts +14 -1
- package/src/cjs/Bounds.js +21 -1
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/CubicBezierCurve.d.ts +70 -1
- package/src/cjs/CubicBezierCurve.js +130 -12
- package/src/cjs/CubicBezierCurve.js.map +1 -1
- package/src/cjs/Line.d.ts +2 -1
- package/src/cjs/Line.js +1 -0
- package/src/cjs/Line.js.map +1 -1
- package/src/cjs/PBText.d.ts +2 -1
- package/src/cjs/PBText.js +10 -9
- package/src/cjs/PBText.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +4 -13
- package/src/cjs/PlotBoilerplate.js +61 -15
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Polygon.d.ts +35 -1
- package/src/cjs/Polygon.js +87 -1
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/VEllipse.js +1 -1
- package/src/cjs/VEllipse.js.map +1 -1
- package/src/cjs/Vector.d.ts +4 -4
- package/src/cjs/Vector.js +2 -2
- package/src/cjs/Vector.js.map +1 -1
- package/src/cjs/VertTuple.d.ts +2 -1
- package/src/cjs/VertTuple.js +4 -3
- package/src/cjs/VertTuple.js.map +1 -1
- package/src/cjs/Vertex.d.ts +14 -3
- package/src/cjs/Vertex.js +18 -3
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/draw.d.ts +154 -75
- package/src/cjs/draw.js +308 -137
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.d.ts +87 -50
- package/src/cjs/drawgl.js +86 -31
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +226 -53
- package/src/cjs/drawutilssvg.js +374 -92
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +157 -79
- package/src/cjs/interfaces/DrawLib.js +6 -0
- package/src/cjs/interfaces/DrawLib.js.map +1 -1
- package/src/cjs/interfaces/core.d.ts +13 -2
- package/src/cjs/interfaces/core.js +1 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/creategui.js +16 -10
- package/src/cjs/utils/detectDarkMode.d.ts +10 -0
- package/src/cjs/utils/detectDarkMode.js +32 -0
- package/src/cjs/utils/detectDarkMode.js.map +1 -0
- package/src/esm/BezierPath.d.ts +27 -49
- package/src/esm/BezierPath.js +67 -234
- package/src/esm/BezierPath.js.map +1 -1
- package/src/esm/Bounds.d.ts +14 -1
- package/src/esm/Bounds.js +19 -1
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/CubicBezierCurve.d.ts +70 -1
- package/src/esm/CubicBezierCurve.js +130 -12
- package/src/esm/CubicBezierCurve.js.map +1 -1
- package/src/esm/Line.d.ts +2 -1
- package/src/esm/Line.js +1 -0
- package/src/esm/Line.js.map +1 -1
- package/src/esm/PBText.d.ts +2 -1
- package/src/esm/PBText.js +10 -9
- package/src/esm/PBText.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +4 -13
- package/src/esm/PlotBoilerplate.js +62 -16
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Polygon.d.ts +35 -1
- package/src/esm/Polygon.js +85 -1
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/VEllipse.js +1 -1
- package/src/esm/VEllipse.js.map +1 -1
- package/src/esm/Vector.d.ts +4 -4
- package/src/esm/Vector.js +2 -2
- package/src/esm/Vector.js.map +1 -1
- package/src/esm/VertTuple.d.ts +2 -1
- package/src/esm/VertTuple.js +4 -3
- package/src/esm/VertTuple.js.map +1 -1
- package/src/esm/Vertex.d.ts +14 -3
- package/src/esm/Vertex.js +18 -3
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/draw.d.ts +154 -75
- package/src/esm/draw.js +304 -135
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.d.ts +87 -50
- package/src/esm/drawgl.js +86 -31
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +226 -53
- package/src/esm/drawutilssvg.js +369 -92
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +157 -79
- package/src/esm/interfaces/DrawLib.js +6 -0
- package/src/esm/interfaces/DrawLib.js.map +1 -1
- package/src/esm/interfaces/core.d.ts +13 -2
- package/src/esm/interfaces/core.js +1 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/detectDarkMode.d.ts +10 -0
- package/src/esm/utils/detectDarkMode.js +28 -0
- package/src/esm/utils/detectDarkMode.js.map +1 -0
- package/src/ts/BezierPath.ts +72 -241
- package/src/ts/Bounds.ts +25 -1
- package/src/ts/CubicBezierCurve.ts +139 -12
- package/src/ts/Line.ts +2 -1
- package/src/ts/PBText.ts +10 -9
- package/src/ts/PlotBoilerplate.ts +56 -19
- package/src/ts/Polygon.ts +91 -1
- package/src/ts/VEllipse.ts +2 -2
- package/src/ts/Vector.ts +4 -4
- package/src/ts/VertTuple.ts +4 -3
- package/src/ts/Vertex.ts +20 -4
- package/src/ts/draw.ts +311 -115
- package/src/ts/drawgl.ts +133 -71
- package/src/ts/drawutilssvg.ts +543 -121
- package/src/ts/interfaces/DrawLib.ts +219 -83
- package/src/ts/interfaces/core.ts +14 -2
- package/src/ts/utils/detectDarkMode.ts +30 -0
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
* @modified 2022-02-03 Added the `cross(...)` function.
|
|
20
20
|
* @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
|
|
21
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.
|
|
22
28
|
**/
|
|
23
29
|
|
|
24
30
|
import { Bounds } from "../Bounds";
|
|
@@ -50,6 +56,20 @@ export interface FontOptions {
|
|
|
50
56
|
rotation?: number;
|
|
51
57
|
}
|
|
52
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
|
+
|
|
53
73
|
/**
|
|
54
74
|
* An interface all drawing libraries must implement to be used with PlotBoilerplate.
|
|
55
75
|
*
|
|
@@ -72,6 +92,21 @@ export interface DrawLib<R> {
|
|
|
72
92
|
*/
|
|
73
93
|
setConfiguration: (configuration: DrawLibConfiguration) => void;
|
|
74
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
|
+
|
|
75
110
|
/**
|
|
76
111
|
* This method shouled be called each time the currently drawn `Drawable` changes.
|
|
77
112
|
* It is used by some libraries for identifying elemente on re-renders.
|
|
@@ -120,29 +155,84 @@ export interface DrawLib<R> {
|
|
|
120
155
|
* Draw the line between the given two points with the specified (CSS-) color.
|
|
121
156
|
*
|
|
122
157
|
* @method line
|
|
123
|
-
* @param {
|
|
124
|
-
* @param {
|
|
158
|
+
* @param {XYCoords} zA - The start point of the line.
|
|
159
|
+
* @param {XYCoords} zB - The end point of the line.
|
|
125
160
|
* @param {string} color - Any valid CSS color string.
|
|
126
|
-
* @param {number=1} lineWidth? -
|
|
127
|
-
* @
|
|
161
|
+
* @param {number=1} lineWidth? - (optional) The line's width.
|
|
162
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
163
|
+
* @return {R}
|
|
128
164
|
* @instance
|
|
129
165
|
* @memberof DrawLib
|
|
130
166
|
**/
|
|
131
|
-
line: (zA:
|
|
167
|
+
line: (zA: XYCoords, zB: XYCoords, color: string, lineWidth?: number, strokeOptopns?: StrokeOptions) => R;
|
|
132
168
|
|
|
133
169
|
/**
|
|
134
|
-
* Draw a line and an arrow at the end (zB) of the given line
|
|
170
|
+
* Draw a line and an arrow at the end (zB) of the given line width the specified (CSS-) color and size.
|
|
135
171
|
*
|
|
136
172
|
* @method arrow
|
|
137
|
-
* @param {
|
|
138
|
-
* @param {
|
|
173
|
+
* @param {XYCoords} zA - The start point of the arrow-line.
|
|
174
|
+
* @param {XYCoords} zB - The end point of the arrow-line.
|
|
139
175
|
* @param {string} color - Any valid CSS color string.
|
|
140
|
-
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
141
|
-
* @
|
|
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}
|
|
142
180
|
* @instance
|
|
143
181
|
* @memberof DrawLib
|
|
144
182
|
**/
|
|
145
|
-
arrow: (zA:
|
|
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;
|
|
146
236
|
|
|
147
237
|
/**
|
|
148
238
|
* Draw an image at the given position with the given size.<br>
|
|
@@ -151,14 +241,14 @@ export interface DrawLib<R> {
|
|
|
151
241
|
*
|
|
152
242
|
* @method image
|
|
153
243
|
* @param {Image} image - The image object to draw.
|
|
154
|
-
* @param {
|
|
155
|
-
* @param {
|
|
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.
|
|
156
246
|
* @param {number=1.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).
|
|
157
|
-
* @return {
|
|
247
|
+
* @return {R}
|
|
158
248
|
* @instance
|
|
159
249
|
* @memberof DrawLib
|
|
160
250
|
**/
|
|
161
|
-
image: (image: HTMLImageElement, position:
|
|
251
|
+
image: (image: HTMLImageElement, position: XYCoords, size: XYCoords, alpha?: number) => R;
|
|
162
252
|
|
|
163
253
|
/**
|
|
164
254
|
* Draw an image at the given position with the given size.<br>
|
|
@@ -169,7 +259,7 @@ export interface DrawLib<R> {
|
|
|
169
259
|
* @param {Image} textureImage - The image object to draw.
|
|
170
260
|
* @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.
|
|
171
261
|
* @param {Polygon} polygon - The polygon to use as clip path.
|
|
172
|
-
* @param {
|
|
262
|
+
* @param {XYCoords} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
|
|
173
263
|
* @param {number} rotation - The rotation to use for the polygon (and for the texture).
|
|
174
264
|
* @return {void}
|
|
175
265
|
* @instance
|
|
@@ -179,7 +269,7 @@ export interface DrawLib<R> {
|
|
|
179
269
|
textureImage: HTMLImageElement,
|
|
180
270
|
textureSize: Bounds,
|
|
181
271
|
polygon: Polygon,
|
|
182
|
-
polygonPosition:
|
|
272
|
+
polygonPosition: XYCoords,
|
|
183
273
|
rotation: number
|
|
184
274
|
) => R;
|
|
185
275
|
|
|
@@ -187,23 +277,26 @@ export interface DrawLib<R> {
|
|
|
187
277
|
* Draw the given (cubic) bézier curve.
|
|
188
278
|
*
|
|
189
279
|
* @method cubicBezier
|
|
190
|
-
* @param {
|
|
191
|
-
* @param {
|
|
192
|
-
* @param {
|
|
193
|
-
* @param {
|
|
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.
|
|
194
284
|
* @param {string} color - The CSS color to draw the curve with.
|
|
195
285
|
* @param {number} lineWidth - (optional) The line width to use.
|
|
196
|
-
* @
|
|
286
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
287
|
+
*
|
|
288
|
+
* @return {R}
|
|
197
289
|
* @instance
|
|
198
290
|
* @memberof DrawLib
|
|
199
291
|
*/
|
|
200
292
|
cubicBezier: (
|
|
201
|
-
startPoint:
|
|
202
|
-
endPoint:
|
|
203
|
-
startControlPoint:
|
|
204
|
-
endControlPoint:
|
|
293
|
+
startPoint: XYCoords,
|
|
294
|
+
endPoint: XYCoords,
|
|
295
|
+
startControlPoint: XYCoords,
|
|
296
|
+
endControlPoint: XYCoords,
|
|
205
297
|
color: string,
|
|
206
|
-
lineWidth?: number
|
|
298
|
+
lineWidth?: number,
|
|
299
|
+
strokeOptopns?: StrokeOptions
|
|
207
300
|
) => R;
|
|
208
301
|
|
|
209
302
|
/**
|
|
@@ -214,14 +307,16 @@ export interface DrawLib<R> {
|
|
|
214
307
|
* <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>
|
|
215
308
|
*
|
|
216
309
|
* @method cubicBezierPath
|
|
217
|
-
* @param {
|
|
310
|
+
* @param {XYCoords[]} path - The cubic bezier path as described above.
|
|
218
311
|
* @param {string} color - The CSS colot to draw the path with.
|
|
219
312
|
* @param {number=1} lineWidth - (optional) The line width to use.
|
|
220
|
-
* @
|
|
313
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
314
|
+
*
|
|
315
|
+
* @return {R}
|
|
221
316
|
* @instance
|
|
222
317
|
* @memberof DrawLib
|
|
223
318
|
*/
|
|
224
|
-
cubicBezierPath: (path: Array<
|
|
319
|
+
cubicBezierPath: (path: Array<XYCoords>, color: string, lineWidth?: number, strokeOptopns?: StrokeOptions) => R;
|
|
225
320
|
|
|
226
321
|
/**
|
|
227
322
|
* Draw the given handle and handle point (used to draw interactive Bézier curves).
|
|
@@ -229,49 +324,49 @@ export interface DrawLib<R> {
|
|
|
229
324
|
* The colors for this are fixed and cannot be specified.
|
|
230
325
|
*
|
|
231
326
|
* @method handle
|
|
232
|
-
* @param {
|
|
233
|
-
* @param {
|
|
234
|
-
* @return {
|
|
327
|
+
* @param {XYCoords} startPoint - The start of the handle.
|
|
328
|
+
* @param {XYCoords} endPoint - The end point of the handle.
|
|
329
|
+
* @return {R}
|
|
235
330
|
* @instance
|
|
236
331
|
* @memberof DrawLib
|
|
237
332
|
*/
|
|
238
|
-
handle: (startPoint:
|
|
333
|
+
handle: (startPoint: XYCoords, endPoint: XYCoords) => R;
|
|
239
334
|
|
|
240
335
|
/**
|
|
241
336
|
* Draw a handle line (with a light grey).
|
|
242
337
|
*
|
|
243
338
|
* @method handleLine
|
|
244
|
-
* @param {
|
|
245
|
-
* @param {
|
|
246
|
-
* @return {
|
|
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}
|
|
247
342
|
* @instance
|
|
248
343
|
* @memberof DrawLib
|
|
249
344
|
*/
|
|
250
|
-
handleLine: (startPoint:
|
|
345
|
+
handleLine: (startPoint: XYCoords, endPoint: XYCoords) => R;
|
|
251
346
|
|
|
252
347
|
/**
|
|
253
348
|
* Draw a 1x1 dot with the specified (CSS-) color.
|
|
254
349
|
*
|
|
255
350
|
* @method dot
|
|
256
|
-
* @param {
|
|
351
|
+
* @param {XYCoords} p - The position to draw the dot at.
|
|
257
352
|
* @param {string} color - The CSS color to draw the dot with.
|
|
258
|
-
* @return {
|
|
353
|
+
* @return {R}
|
|
259
354
|
* @instance
|
|
260
355
|
* @memberof DrawLib
|
|
261
356
|
*/
|
|
262
|
-
dot: (p:
|
|
357
|
+
dot: (p: XYCoords, color: string) => R;
|
|
263
358
|
|
|
264
359
|
/**
|
|
265
360
|
* Draw the given point with the specified (CSS-) color and radius 3.
|
|
266
361
|
*
|
|
267
362
|
* @method point
|
|
268
|
-
* @param {
|
|
269
|
-
* @param {
|
|
270
|
-
* @return {
|
|
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}
|
|
271
366
|
* @instance
|
|
272
367
|
* @memberof DrawLib
|
|
273
368
|
*/
|
|
274
|
-
point: (p:
|
|
369
|
+
point: (p: XYCoords, color: string) => R;
|
|
275
370
|
|
|
276
371
|
/**
|
|
277
372
|
* Draw a circle with the specified (CSS-) color and radius.<br>
|
|
@@ -279,47 +374,69 @@ export interface DrawLib<R> {
|
|
|
279
374
|
* Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.
|
|
280
375
|
*
|
|
281
376
|
* @method circle
|
|
282
|
-
* @param {
|
|
377
|
+
* @param {XYCoords} center - The center of the circle.
|
|
283
378
|
* @param {number} radius - The radius of the circle.
|
|
284
379
|
* @param {string} color - The CSS color to draw the circle with.
|
|
285
380
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
286
|
-
* @
|
|
381
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
382
|
+
*
|
|
383
|
+
* @return {R}
|
|
287
384
|
* @instance
|
|
288
385
|
* @memberof DrawLib
|
|
289
386
|
*/
|
|
290
|
-
circle: (center:
|
|
387
|
+
circle: (center: XYCoords, radius: number, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
291
388
|
|
|
292
389
|
/**
|
|
293
390
|
* Draw a circular arc (section of a circle) with the given CSS color.
|
|
294
391
|
*
|
|
295
392
|
* @method circleArc
|
|
296
|
-
* @param {
|
|
393
|
+
* @param {XYCoords} center - The center of the circle.
|
|
297
394
|
* @param {number} radius - The radius of the circle.
|
|
298
395
|
* @param {number} startAngle - The angle to start at.
|
|
299
396
|
* @param {number} endAngle - The angle to end at.
|
|
300
397
|
* @param {string} color - The CSS color to draw the circle with.
|
|
301
398
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
302
|
-
* @
|
|
399
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
400
|
+
*
|
|
401
|
+
* @return {R}
|
|
303
402
|
* @instance
|
|
304
403
|
* @memberof DrawLib
|
|
305
404
|
*/
|
|
306
|
-
circleArc: (
|
|
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;
|
|
307
414
|
|
|
308
415
|
/**
|
|
309
416
|
* Draw an ellipse with the specified (CSS-) color and thw two radii.
|
|
310
417
|
*
|
|
311
418
|
* @method ellipse
|
|
312
|
-
* @param {
|
|
419
|
+
* @param {XYCoords} center - The center of the ellipse.
|
|
313
420
|
* @param {number} radiusX - The radius of the ellipse.
|
|
314
421
|
* @param {number} radiusY - The radius of the ellipse.
|
|
315
422
|
* @param {string} color - The CSS color to draw the ellipse with.
|
|
316
423
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
317
424
|
* @param {number=} rotation - (optional, default=0) The rotation of the ellipse.
|
|
318
|
-
* @
|
|
425
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
426
|
+
*
|
|
427
|
+
* @return {R}
|
|
319
428
|
* @instance
|
|
320
429
|
* @memberof DrawLib
|
|
321
430
|
*/
|
|
322
|
-
ellipse: (
|
|
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;
|
|
323
440
|
|
|
324
441
|
/**
|
|
325
442
|
* Draw square at the given center, size and with the specified (CSS-) color.<br>
|
|
@@ -331,11 +448,13 @@ export interface DrawLib<R> {
|
|
|
331
448
|
* @param {number} size - The size of the square.
|
|
332
449
|
* @param {string} color - The CSS color to draw the square with.
|
|
333
450
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
334
|
-
* @
|
|
451
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
452
|
+
*
|
|
453
|
+
* @return {R}
|
|
335
454
|
* @instance
|
|
336
455
|
* @memberof DrawLib
|
|
337
456
|
*/
|
|
338
|
-
square: (center: XYCoords, size: number, color: string, lineWidth?: number) => R;
|
|
457
|
+
square: (center: XYCoords, size: number, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
339
458
|
|
|
340
459
|
/**
|
|
341
460
|
* Draw a rectangle at the given left upper corner, with, height; and with the specified line width and (CSS-) color.<br>
|
|
@@ -346,27 +465,36 @@ export interface DrawLib<R> {
|
|
|
346
465
|
* @param {number} height - The height of the rectangle.
|
|
347
466
|
* @param {string} color - The CSS color to draw the rectangle with.
|
|
348
467
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
349
|
-
* @
|
|
468
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
469
|
+
*
|
|
470
|
+
* @return {R}
|
|
350
471
|
* @instance
|
|
351
472
|
* @memberof DrawLib
|
|
352
473
|
*/
|
|
353
|
-
rect: (
|
|
474
|
+
rect: (
|
|
475
|
+
upperLeft: XYCoords,
|
|
476
|
+
width: number,
|
|
477
|
+
height: number,
|
|
478
|
+
color: string,
|
|
479
|
+
lineWidth?: number,
|
|
480
|
+
strokeOptions?: StrokeOptions
|
|
481
|
+
) => R;
|
|
354
482
|
|
|
355
483
|
/**
|
|
356
484
|
* Draw a grid of horizontal and vertical lines with the given (CSS-) color.
|
|
357
485
|
*
|
|
358
486
|
* @method grid
|
|
359
|
-
* @param {
|
|
487
|
+
* @param {XYCoords} center - The center of the grid.
|
|
360
488
|
* @param {number} width - The total width of the grid (width/2 each to the left and to the right).
|
|
361
489
|
* @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).
|
|
362
490
|
* @param {number} sizeX - The horizontal grid size.
|
|
363
491
|
* @param {number} sizeY - The vertical grid size.
|
|
364
492
|
* @param {string} color - The CSS color to draw the grid with.
|
|
365
|
-
* @return {
|
|
493
|
+
* @return {R}
|
|
366
494
|
* @instance
|
|
367
495
|
* @memberof DrawLib
|
|
368
496
|
*/
|
|
369
|
-
grid: (center:
|
|
497
|
+
grid: (center: XYCoords, width: number, height: number, sizeX: number, sizeY: number, color: string) => R;
|
|
370
498
|
|
|
371
499
|
/**
|
|
372
500
|
* Draw a raster of crosshairs in the given grid.<br>
|
|
@@ -374,17 +502,17 @@ export interface DrawLib<R> {
|
|
|
374
502
|
* This works analogue to the grid() function
|
|
375
503
|
*
|
|
376
504
|
* @method raster
|
|
377
|
-
* @param {
|
|
505
|
+
* @param {XYCoords} center - The center of the raster.
|
|
378
506
|
* @param {number} width - The total width of the raster (width/2 each to the left and to the right).
|
|
379
507
|
* @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).
|
|
380
508
|
* @param {number} sizeX - The horizontal raster size.
|
|
381
509
|
* @param {number} sizeY - The vertical raster size.
|
|
382
510
|
* @param {string} color - The CSS color to draw the raster with.
|
|
383
|
-
* @return {
|
|
511
|
+
* @return {R}
|
|
384
512
|
* @instance
|
|
385
513
|
* @memberof DrawLib
|
|
386
514
|
*/
|
|
387
|
-
raster: (center:
|
|
515
|
+
raster: (center: XYCoords, width: number, height: number, sizeX: number, sizeY: number, color: string) => R;
|
|
388
516
|
|
|
389
517
|
/**
|
|
390
518
|
* Draw a diamond handle (square rotated by 45°) with the given CSS color.
|
|
@@ -394,14 +522,14 @@ export interface DrawLib<R> {
|
|
|
394
522
|
* as even shaped diamonds.
|
|
395
523
|
*
|
|
396
524
|
* @method diamondHandle
|
|
397
|
-
* @param {
|
|
398
|
-
* @param {
|
|
525
|
+
* @param {XYCoords} center - The center of the diamond.
|
|
526
|
+
* @param {number} size - The x/y-size of the diamond.
|
|
399
527
|
* @param {string} color - The CSS color to draw the diamond with.
|
|
400
|
-
* @return {
|
|
528
|
+
* @return {R}
|
|
401
529
|
* @instance
|
|
402
530
|
* @memberof DrawLib
|
|
403
531
|
*/
|
|
404
|
-
diamondHandle: (center:
|
|
532
|
+
diamondHandle: (center: XYCoords, size: number, color: string) => R;
|
|
405
533
|
|
|
406
534
|
/**
|
|
407
535
|
* Draw a square handle with the given CSS color.<br>
|
|
@@ -411,14 +539,14 @@ export interface DrawLib<R> {
|
|
|
411
539
|
* as even shaped squares.
|
|
412
540
|
*
|
|
413
541
|
* @method squareHandle
|
|
414
|
-
* @param {
|
|
415
|
-
* @param {
|
|
542
|
+
* @param {XYCoords} center - The center of the square.
|
|
543
|
+
* @param {number} size - The x/y-size of the square.
|
|
416
544
|
* @param {string} color - The CSS color to draw the square with.
|
|
417
|
-
* @return {
|
|
545
|
+
* @return {R}
|
|
418
546
|
* @instance
|
|
419
547
|
* @memberof DrawLib
|
|
420
548
|
*/
|
|
421
|
-
squareHandle: (center:
|
|
549
|
+
squareHandle: (center: XYCoords, size: number, color: string) => R;
|
|
422
550
|
|
|
423
551
|
/**
|
|
424
552
|
* Draw a circle handle with the given CSS color.<br>
|
|
@@ -428,14 +556,14 @@ export interface DrawLib<R> {
|
|
|
428
556
|
* as even shaped circles.
|
|
429
557
|
*
|
|
430
558
|
* @method circleHandle
|
|
431
|
-
* @param {
|
|
559
|
+
* @param {XYCoords} center - The center of the circle.
|
|
432
560
|
* @param {number} radius - The radius of the circle.
|
|
433
561
|
* @param {string} color - The CSS color to draw the circle with.
|
|
434
|
-
* @return {
|
|
562
|
+
* @return {R}
|
|
435
563
|
* @instance
|
|
436
564
|
* @memberof DrawLib
|
|
437
565
|
*/
|
|
438
|
-
circleHandle: (center:
|
|
566
|
+
circleHandle: (center: XYCoords, size: number, color: string) => R;
|
|
439
567
|
|
|
440
568
|
/**
|
|
441
569
|
* Draw a crosshair with given radius and color at the given position.<br>
|
|
@@ -447,7 +575,7 @@ export interface DrawLib<R> {
|
|
|
447
575
|
* @param {number} radius - The radius of the crosshair.
|
|
448
576
|
* @param {string} color - The CSS color to draw the crosshair with.
|
|
449
577
|
* @param {number=0.5} lineWidth - (optional, default=0.5) The line width to use.
|
|
450
|
-
* @return {
|
|
578
|
+
* @return {R}
|
|
451
579
|
* @instance
|
|
452
580
|
* @memberof DrawLib
|
|
453
581
|
*/
|
|
@@ -463,7 +591,7 @@ export interface DrawLib<R> {
|
|
|
463
591
|
* @param {number} radius - The radius of the crosshair.
|
|
464
592
|
* @param {string} color - The CSS color to draw the crosshair with.
|
|
465
593
|
* @param {number=1} lineWidth - (optional, default=1.0) The line width to use.
|
|
466
|
-
* @return {
|
|
594
|
+
* @return {R}
|
|
467
595
|
* @instance
|
|
468
596
|
* @memberof DrawLib
|
|
469
597
|
*/
|
|
@@ -475,25 +603,30 @@ export interface DrawLib<R> {
|
|
|
475
603
|
* @method polygon
|
|
476
604
|
* @param {Polygon} polygon - The polygon to draw.
|
|
477
605
|
* @param {string} color - The CSS color to draw the polygon with.
|
|
478
|
-
* @
|
|
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}
|
|
479
610
|
* @instance
|
|
480
611
|
* @memberof DrawLib
|
|
481
612
|
*/
|
|
482
|
-
polygon: (polygon: Polygon, color: string, lineWidth?: number) => R;
|
|
613
|
+
polygon: (polygon: Polygon, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
483
614
|
|
|
484
615
|
/**
|
|
485
616
|
* Draw a polygon line (alternative function to the polygon).
|
|
486
617
|
*
|
|
487
618
|
* @method polyline
|
|
488
|
-
* @param {
|
|
619
|
+
* @param {XYCoords[]} vertices - The polygon vertices to draw.
|
|
489
620
|
* @param {boolan} isOpen - If true the polyline will not be closed at its end.
|
|
490
621
|
* @param {string} color - The CSS color to draw the polygon with.
|
|
491
622
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
492
|
-
* @
|
|
623
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
624
|
+
*
|
|
625
|
+
* @return {R}
|
|
493
626
|
* @instance
|
|
494
627
|
* @memberof DrawLib
|
|
495
628
|
*/
|
|
496
|
-
polyline: (vertices: Array<
|
|
629
|
+
polyline: (vertices: Array<XYCoords>, isOpen: boolean, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
497
630
|
|
|
498
631
|
/**
|
|
499
632
|
* Draw a text at the given relative position.
|
|
@@ -539,11 +672,14 @@ export interface DrawLib<R> {
|
|
|
539
672
|
* @param {string=null} color - (optional) The color to draw this path with (default is null).
|
|
540
673
|
* @param {number=1} lineWidth - (optional) the line width to use (default is 1).
|
|
541
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
|
+
*
|
|
542
678
|
* @instance
|
|
543
679
|
* @memberof DrawLib
|
|
544
680
|
* @return {R} An instance representing the drawn path.
|
|
545
681
|
*/
|
|
546
|
-
path: (pathData: SVGPathParams, color?: string, lineWidth?: number, options?: { inplace?: boolean }) => R;
|
|
682
|
+
path: (pathData: SVGPathParams, color?: string, lineWidth?: number, options?: { inplace?: boolean } & StrokeOptions) => R;
|
|
547
683
|
|
|
548
684
|
/**
|
|
549
685
|
* Due to gl compatibility there is a generic 'clear' function required
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* @modified 2022-10-25 Added `origin` param to the `DrawConfig` interface.
|
|
19
19
|
* @modified 2022-11-23 Added `drawRaster` to the `Config` interface.
|
|
20
20
|
* @modified 2023-02-10 All non-function attributes of the `Config` interface are now mandatory.
|
|
21
|
+
* @modified 2023-09-29 Added the `randomPoint(...)` function declaration to the IBounds interface.
|
|
21
22
|
**/
|
|
22
23
|
|
|
23
24
|
import { Vertex } from "../Vertex";
|
|
@@ -67,6 +68,16 @@ export interface IBounds {
|
|
|
67
68
|
min: XYCoords;
|
|
68
69
|
max: XYCoords;
|
|
69
70
|
getCenter(): Vertex;
|
|
71
|
+
/**
|
|
72
|
+
* Generate a random point inside this bounds object. Safe areas at the border to avoid
|
|
73
|
+
* included.
|
|
74
|
+
*
|
|
75
|
+
* @method randomPoint
|
|
76
|
+
* @param {horizontalSafeArea} - (optional) The horizonal (left and right) safe area. No vertex will be created here. Can be used as percent in (0.0 ... 0.1) interval.
|
|
77
|
+
* @param {verticalSafeArea} - (optional) The vertical (top and bottom) safe area. No vertex will be created here. Can be used as percent in (0.0 ... 0.1) interval
|
|
78
|
+
* @returns {Vertex} A pseudo random point inside these bounds.
|
|
79
|
+
*/
|
|
80
|
+
randomPoint: (horizontalSafeArea?: number, verticalSafeArea?: number) => Vertex;
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
/**
|
|
@@ -101,8 +112,9 @@ export interface CanvasWrapper {
|
|
|
101
112
|
/**
|
|
102
113
|
* The config that's used by PB.
|
|
103
114
|
*/
|
|
104
|
-
export interface Config
|
|
105
|
-
|
|
115
|
+
export interface Config
|
|
116
|
+
extends Record<string, boolean | number | string | Function | HTMLCanvasElement | SVGElement | undefined> {
|
|
117
|
+
canvas: HTMLCanvasElement | SVGElement | string; // Your canvas element in the DOM (required).
|
|
106
118
|
fullSize: boolean; // If set to true the canvas will gain full window size.
|
|
107
119
|
fitToParent: boolean; // If set to true the canvas will gain the size of its parent container (overrides fullSize).
|
|
108
120
|
scaleX: number; // The initial x-zoom. Default is 1.0.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author Ikaros Kappler
|
|
3
|
+
* @date 2021-11-07
|
|
4
|
+
* @modified 2023-09-25 Ported to Typescript and added system darkmode detection.
|
|
5
|
+
* @version 1.1.0
|
|
6
|
+
*
|
|
7
|
+
* @param {Record<string,string>} GUP
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import PlotBoilerplate from "../PlotBoilerplate";
|
|
12
|
+
|
|
13
|
+
export const detectDarkMode = (GUP?: Record<string, string>) => {
|
|
14
|
+
// Respect overrides
|
|
15
|
+
if (typeof GUP !== "undefined" && GUP.hasOwnProperty("darkmode") && GUP["darkmode"]) {
|
|
16
|
+
// const overrideValue = PlotBoilerplate.utils.fetch.bool(GUP, "darkmode", null);
|
|
17
|
+
const overrideValue = !!JSON.parse(GUP["darkmode"]);
|
|
18
|
+
if (overrideValue !== null) {
|
|
19
|
+
return overrideValue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (globalThis.matchMedia && globalThis.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
23
|
+
// dark mode by system
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
// else: dark mode by daytime
|
|
27
|
+
const hours = new Date().getHours();
|
|
28
|
+
const isDayTime = hours > 6 && hours < 18;
|
|
29
|
+
return !isDayTime;
|
|
30
|
+
};
|