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
|
import { Bounds } from "../Bounds";
|
|
24
30
|
import { Polygon } from "../Polygon";
|
|
@@ -39,6 +45,19 @@ export interface FontOptions {
|
|
|
39
45
|
textAlign?: CanvasRenderingContext2D["textAlign"];
|
|
40
46
|
rotation?: number;
|
|
41
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Defines a line-dash configuration.
|
|
50
|
+
*
|
|
51
|
+
* See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
|
|
52
|
+
* and https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
53
|
+
* for how line dashes work.
|
|
54
|
+
*
|
|
55
|
+
* Setting line-dash to empty array `[]` resets the dashing.
|
|
56
|
+
*/
|
|
57
|
+
export interface StrokeOptions {
|
|
58
|
+
dashOffset?: number;
|
|
59
|
+
dashArray?: Array<number>;
|
|
60
|
+
}
|
|
42
61
|
/**
|
|
43
62
|
* An interface all drawing libraries must implement to be used with PlotBoilerplate.
|
|
44
63
|
*
|
|
@@ -103,28 +122,65 @@ export interface DrawLib<R> {
|
|
|
103
122
|
* Draw the line between the given two points with the specified (CSS-) color.
|
|
104
123
|
*
|
|
105
124
|
* @method line
|
|
106
|
-
* @param {
|
|
107
|
-
* @param {
|
|
125
|
+
* @param {XYCoords} zA - The start point of the line.
|
|
126
|
+
* @param {XYCoords} zB - The end point of the line.
|
|
108
127
|
* @param {string} color - Any valid CSS color string.
|
|
109
|
-
* @param {number=1} lineWidth? -
|
|
110
|
-
* @
|
|
128
|
+
* @param {number=1} lineWidth? - (optional) The line's width.
|
|
129
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
130
|
+
* @return {R}
|
|
111
131
|
* @instance
|
|
112
132
|
* @memberof DrawLib
|
|
113
133
|
**/
|
|
114
|
-
line: (zA:
|
|
134
|
+
line: (zA: XYCoords, zB: XYCoords, color: string, lineWidth?: number, strokeOptopns?: StrokeOptions) => R;
|
|
115
135
|
/**
|
|
116
|
-
* Draw a line and an arrow at the end (zB) of the given line
|
|
136
|
+
* Draw a line and an arrow at the end (zB) of the given line width the specified (CSS-) color and size.
|
|
117
137
|
*
|
|
118
138
|
* @method arrow
|
|
119
|
-
* @param {
|
|
120
|
-
* @param {
|
|
139
|
+
* @param {XYCoords} zA - The start point of the arrow-line.
|
|
140
|
+
* @param {XYCoords} zB - The end point of the arrow-line.
|
|
121
141
|
* @param {string} color - Any valid CSS color string.
|
|
122
|
-
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
123
|
-
* @
|
|
142
|
+
* @param {number=1} lineWidth - (optional) The line width to use; default is 1.
|
|
143
|
+
* @param {headLength=8} headLength - (optional) The length of the arrow head (default is 8 units).
|
|
144
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
145
|
+
* @return {R}
|
|
146
|
+
* @instance
|
|
147
|
+
* @memberof DrawLib
|
|
148
|
+
**/
|
|
149
|
+
arrow: (zA: XYCoords, zB: XYCoords, color: string, lineWidth?: number, headLength?: number, strokeOptopns?: StrokeOptions) => R;
|
|
150
|
+
/**
|
|
151
|
+
* 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.
|
|
152
|
+
*
|
|
153
|
+
* @method cubicBezierArrow
|
|
154
|
+
* @param {XYCoords} startPoint - The start point of the cubic Bézier curve
|
|
155
|
+
* @param {XYCoords} endPoint - The end point the cubic Bézier curve.
|
|
156
|
+
* @param {XYCoords} startControlPoint - The start control point the cubic Bézier curve.
|
|
157
|
+
* @param {XYCoords} endControlPoint - The end control point the cubic Bézier curve.
|
|
158
|
+
* @param {string} color - The CSS color to draw the curve with.
|
|
159
|
+
* @param {number} lineWidth - (optional) The line width to use.
|
|
160
|
+
* @param {headLength=8} headLength - (optional) The length of the arrow head (default is 8 units).
|
|
161
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
162
|
+
*
|
|
163
|
+
* @return {R}
|
|
164
|
+
* @instance
|
|
165
|
+
* @memberof DrawLib
|
|
166
|
+
*/
|
|
167
|
+
cubicBezierArrow: (startPoint: XYCoords, endPoint: XYCoords, startControlPoint: XYCoords, endControlPoint: XYCoords, color: string, lineWidth?: number, headLength?: number, strokeOptopns?: StrokeOptions) => R;
|
|
168
|
+
/**
|
|
169
|
+
* Draw just an arrow head a the end of an imaginary line (zB) of the given line width the specified (CSS-) color and size.
|
|
170
|
+
*
|
|
171
|
+
* @method arrow
|
|
172
|
+
* @param {XYCoords} zA - The start point of the arrow-line.
|
|
173
|
+
* @param {XYCoords} zB - The end point of the arrow-line.
|
|
174
|
+
* @param {string} color - Any valid CSS color string.
|
|
175
|
+
* @param {number=1} lineWidth - (optional) The line width to use; default is 1.
|
|
176
|
+
* @param {number=8} headLength - (optional) The length of the arrow head (default is 8 pixels).
|
|
177
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
178
|
+
*
|
|
179
|
+
* @return {R}
|
|
124
180
|
* @instance
|
|
125
181
|
* @memberof DrawLib
|
|
126
182
|
**/
|
|
127
|
-
|
|
183
|
+
arrowHead: (zA: XYCoords, zB: XYCoords, color: string, lineWidth?: number, headLength?: number, strokeOptopns?: StrokeOptions) => R;
|
|
128
184
|
/**
|
|
129
185
|
* Draw an image at the given position with the given size.<br>
|
|
130
186
|
* <br>
|
|
@@ -132,14 +188,14 @@ export interface DrawLib<R> {
|
|
|
132
188
|
*
|
|
133
189
|
* @method image
|
|
134
190
|
* @param {Image} image - The image object to draw.
|
|
135
|
-
* @param {
|
|
136
|
-
* @param {
|
|
191
|
+
* @param {XYCoords} position - The position to draw the the upper left corner at.
|
|
192
|
+
* @param {XYCoords} size - The x/y-size to draw the image with.
|
|
137
193
|
* @param {number=1.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).
|
|
138
|
-
* @return {
|
|
194
|
+
* @return {R}
|
|
139
195
|
* @instance
|
|
140
196
|
* @memberof DrawLib
|
|
141
197
|
**/
|
|
142
|
-
image: (image: HTMLImageElement, position:
|
|
198
|
+
image: (image: HTMLImageElement, position: XYCoords, size: XYCoords, alpha?: number) => R;
|
|
143
199
|
/**
|
|
144
200
|
* Draw an image at the given position with the given size.<br>
|
|
145
201
|
* <br>
|
|
@@ -149,28 +205,30 @@ export interface DrawLib<R> {
|
|
|
149
205
|
* @param {Image} textureImage - The image object to draw.
|
|
150
206
|
* @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.
|
|
151
207
|
* @param {Polygon} polygon - The polygon to use as clip path.
|
|
152
|
-
* @param {
|
|
208
|
+
* @param {XYCoords} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
|
|
153
209
|
* @param {number} rotation - The rotation to use for the polygon (and for the texture).
|
|
154
210
|
* @return {void}
|
|
155
211
|
* @instance
|
|
156
212
|
* @memberof DrawLib
|
|
157
213
|
**/
|
|
158
|
-
texturedPoly: (textureImage: HTMLImageElement, textureSize: Bounds, polygon: Polygon, polygonPosition:
|
|
214
|
+
texturedPoly: (textureImage: HTMLImageElement, textureSize: Bounds, polygon: Polygon, polygonPosition: XYCoords, rotation: number) => R;
|
|
159
215
|
/**
|
|
160
216
|
* Draw the given (cubic) bézier curve.
|
|
161
217
|
*
|
|
162
218
|
* @method cubicBezier
|
|
163
|
-
* @param {
|
|
164
|
-
* @param {
|
|
165
|
-
* @param {
|
|
166
|
-
* @param {
|
|
219
|
+
* @param {XYCoords} startPoint - The start point of the cubic Bézier curve
|
|
220
|
+
* @param {XYCoords} endPoint - The end point the cubic Bézier curve.
|
|
221
|
+
* @param {XYCoords} startControlPoint - The start control point the cubic Bézier curve.
|
|
222
|
+
* @param {XYCoords} endControlPoint - The end control point the cubic Bézier curve.
|
|
167
223
|
* @param {string} color - The CSS color to draw the curve with.
|
|
168
224
|
* @param {number} lineWidth - (optional) The line width to use.
|
|
169
|
-
* @
|
|
225
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
226
|
+
*
|
|
227
|
+
* @return {R}
|
|
170
228
|
* @instance
|
|
171
229
|
* @memberof DrawLib
|
|
172
230
|
*/
|
|
173
|
-
cubicBezier: (startPoint:
|
|
231
|
+
cubicBezier: (startPoint: XYCoords, endPoint: XYCoords, startControlPoint: XYCoords, endControlPoint: XYCoords, color: string, lineWidth?: number, strokeOptopns?: StrokeOptions) => R;
|
|
174
232
|
/**
|
|
175
233
|
* Draw the given (cubic) Bézier path.
|
|
176
234
|
*
|
|
@@ -179,105 +237,113 @@ export interface DrawLib<R> {
|
|
|
179
237
|
* <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>
|
|
180
238
|
*
|
|
181
239
|
* @method cubicBezierPath
|
|
182
|
-
* @param {
|
|
240
|
+
* @param {XYCoords[]} path - The cubic bezier path as described above.
|
|
183
241
|
* @param {string} color - The CSS colot to draw the path with.
|
|
184
242
|
* @param {number=1} lineWidth - (optional) The line width to use.
|
|
185
|
-
* @
|
|
243
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
244
|
+
*
|
|
245
|
+
* @return {R}
|
|
186
246
|
* @instance
|
|
187
247
|
* @memberof DrawLib
|
|
188
248
|
*/
|
|
189
|
-
cubicBezierPath: (path: Array<
|
|
249
|
+
cubicBezierPath: (path: Array<XYCoords>, color: string, lineWidth?: number, strokeOptopns?: StrokeOptions) => R;
|
|
190
250
|
/**
|
|
191
251
|
* Draw the given handle and handle point (used to draw interactive Bézier curves).
|
|
192
252
|
*
|
|
193
253
|
* The colors for this are fixed and cannot be specified.
|
|
194
254
|
*
|
|
195
255
|
* @method handle
|
|
196
|
-
* @param {
|
|
197
|
-
* @param {
|
|
198
|
-
* @return {
|
|
256
|
+
* @param {XYCoords} startPoint - The start of the handle.
|
|
257
|
+
* @param {XYCoords} endPoint - The end point of the handle.
|
|
258
|
+
* @return {R}
|
|
199
259
|
* @instance
|
|
200
260
|
* @memberof DrawLib
|
|
201
261
|
*/
|
|
202
|
-
handle: (startPoint:
|
|
262
|
+
handle: (startPoint: XYCoords, endPoint: XYCoords) => R;
|
|
203
263
|
/**
|
|
204
264
|
* Draw a handle line (with a light grey).
|
|
205
265
|
*
|
|
206
266
|
* @method handleLine
|
|
207
|
-
* @param {
|
|
208
|
-
* @param {
|
|
209
|
-
* @return {
|
|
267
|
+
* @param {XYCoords} startPoint - The start point to draw the handle at.
|
|
268
|
+
* @param {XYCoords} endPoint - The end point to draw the handle at.
|
|
269
|
+
* @return {R}
|
|
210
270
|
* @instance
|
|
211
271
|
* @memberof DrawLib
|
|
212
272
|
*/
|
|
213
|
-
handleLine: (startPoint:
|
|
273
|
+
handleLine: (startPoint: XYCoords, endPoint: XYCoords) => R;
|
|
214
274
|
/**
|
|
215
275
|
* Draw a 1x1 dot with the specified (CSS-) color.
|
|
216
276
|
*
|
|
217
277
|
* @method dot
|
|
218
|
-
* @param {
|
|
278
|
+
* @param {XYCoords} p - The position to draw the dot at.
|
|
219
279
|
* @param {string} color - The CSS color to draw the dot with.
|
|
220
|
-
* @return {
|
|
280
|
+
* @return {R}
|
|
221
281
|
* @instance
|
|
222
282
|
* @memberof DrawLib
|
|
223
283
|
*/
|
|
224
|
-
dot: (p:
|
|
284
|
+
dot: (p: XYCoords, color: string) => R;
|
|
225
285
|
/**
|
|
226
286
|
* Draw the given point with the specified (CSS-) color and radius 3.
|
|
227
287
|
*
|
|
228
288
|
* @method point
|
|
229
|
-
* @param {
|
|
230
|
-
* @param {
|
|
231
|
-
* @return {
|
|
289
|
+
* @param {XYCoords} p - The position to draw the point at.
|
|
290
|
+
* @param {XYCoords} color - The CSS color to draw the point with.
|
|
291
|
+
* @return {R}
|
|
232
292
|
* @instance
|
|
233
293
|
* @memberof DrawLib
|
|
234
294
|
*/
|
|
235
|
-
point: (p:
|
|
295
|
+
point: (p: XYCoords, color: string) => R;
|
|
236
296
|
/**
|
|
237
297
|
* Draw a circle with the specified (CSS-) color and radius.<br>
|
|
238
298
|
* <br>
|
|
239
299
|
* Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.
|
|
240
300
|
*
|
|
241
301
|
* @method circle
|
|
242
|
-
* @param {
|
|
302
|
+
* @param {XYCoords} center - The center of the circle.
|
|
243
303
|
* @param {number} radius - The radius of the circle.
|
|
244
304
|
* @param {string} color - The CSS color to draw the circle with.
|
|
245
305
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
246
|
-
* @
|
|
306
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
307
|
+
*
|
|
308
|
+
* @return {R}
|
|
247
309
|
* @instance
|
|
248
310
|
* @memberof DrawLib
|
|
249
311
|
*/
|
|
250
|
-
circle: (center:
|
|
312
|
+
circle: (center: XYCoords, radius: number, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
251
313
|
/**
|
|
252
314
|
* Draw a circular arc (section of a circle) with the given CSS color.
|
|
253
315
|
*
|
|
254
316
|
* @method circleArc
|
|
255
|
-
* @param {
|
|
317
|
+
* @param {XYCoords} center - The center of the circle.
|
|
256
318
|
* @param {number} radius - The radius of the circle.
|
|
257
319
|
* @param {number} startAngle - The angle to start at.
|
|
258
320
|
* @param {number} endAngle - The angle to end at.
|
|
259
321
|
* @param {string} color - The CSS color to draw the circle with.
|
|
260
322
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
261
|
-
* @
|
|
323
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
324
|
+
*
|
|
325
|
+
* @return {R}
|
|
262
326
|
* @instance
|
|
263
327
|
* @memberof DrawLib
|
|
264
328
|
*/
|
|
265
|
-
circleArc: (center:
|
|
329
|
+
circleArc: (center: XYCoords, radius: number, startAngle: number, endAngle: number, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
266
330
|
/**
|
|
267
331
|
* Draw an ellipse with the specified (CSS-) color and thw two radii.
|
|
268
332
|
*
|
|
269
333
|
* @method ellipse
|
|
270
|
-
* @param {
|
|
334
|
+
* @param {XYCoords} center - The center of the ellipse.
|
|
271
335
|
* @param {number} radiusX - The radius of the ellipse.
|
|
272
336
|
* @param {number} radiusY - The radius of the ellipse.
|
|
273
337
|
* @param {string} color - The CSS color to draw the ellipse with.
|
|
274
338
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
275
339
|
* @param {number=} rotation - (optional, default=0) The rotation of the ellipse.
|
|
276
|
-
* @
|
|
340
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
341
|
+
*
|
|
342
|
+
* @return {R}
|
|
277
343
|
* @instance
|
|
278
344
|
* @memberof DrawLib
|
|
279
345
|
*/
|
|
280
|
-
ellipse: (center:
|
|
346
|
+
ellipse: (center: XYCoords, radiusX: number, radiusY: number, color: string, lineWidth?: number, rotation?: number, strokeOptions?: StrokeOptions) => R;
|
|
281
347
|
/**
|
|
282
348
|
* Draw square at the given center, size and with the specified (CSS-) color.<br>
|
|
283
349
|
* <br>
|
|
@@ -288,11 +354,13 @@ export interface DrawLib<R> {
|
|
|
288
354
|
* @param {number} size - The size of the square.
|
|
289
355
|
* @param {string} color - The CSS color to draw the square with.
|
|
290
356
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
291
|
-
* @
|
|
357
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
358
|
+
*
|
|
359
|
+
* @return {R}
|
|
292
360
|
* @instance
|
|
293
361
|
* @memberof DrawLib
|
|
294
362
|
*/
|
|
295
|
-
square: (center: XYCoords, size: number, color: string, lineWidth?: number) => R;
|
|
363
|
+
square: (center: XYCoords, size: number, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
296
364
|
/**
|
|
297
365
|
* Draw a rectangle at the given left upper corner, with, height; and with the specified line width and (CSS-) color.<br>
|
|
298
366
|
*
|
|
@@ -302,43 +370,45 @@ export interface DrawLib<R> {
|
|
|
302
370
|
* @param {number} height - The height of the rectangle.
|
|
303
371
|
* @param {string} color - The CSS color to draw the rectangle with.
|
|
304
372
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
305
|
-
* @
|
|
373
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
374
|
+
*
|
|
375
|
+
* @return {R}
|
|
306
376
|
* @instance
|
|
307
377
|
* @memberof DrawLib
|
|
308
378
|
*/
|
|
309
|
-
rect: (upperLeft: XYCoords, width: number, height: number, color: string, lineWidth?: number) => R;
|
|
379
|
+
rect: (upperLeft: XYCoords, width: number, height: number, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
310
380
|
/**
|
|
311
381
|
* Draw a grid of horizontal and vertical lines with the given (CSS-) color.
|
|
312
382
|
*
|
|
313
383
|
* @method grid
|
|
314
|
-
* @param {
|
|
384
|
+
* @param {XYCoords} center - The center of the grid.
|
|
315
385
|
* @param {number} width - The total width of the grid (width/2 each to the left and to the right).
|
|
316
386
|
* @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).
|
|
317
387
|
* @param {number} sizeX - The horizontal grid size.
|
|
318
388
|
* @param {number} sizeY - The vertical grid size.
|
|
319
389
|
* @param {string} color - The CSS color to draw the grid with.
|
|
320
|
-
* @return {
|
|
390
|
+
* @return {R}
|
|
321
391
|
* @instance
|
|
322
392
|
* @memberof DrawLib
|
|
323
393
|
*/
|
|
324
|
-
grid: (center:
|
|
394
|
+
grid: (center: XYCoords, width: number, height: number, sizeX: number, sizeY: number, color: string) => R;
|
|
325
395
|
/**
|
|
326
396
|
* Draw a raster of crosshairs in the given grid.<br>
|
|
327
397
|
*
|
|
328
398
|
* This works analogue to the grid() function
|
|
329
399
|
*
|
|
330
400
|
* @method raster
|
|
331
|
-
* @param {
|
|
401
|
+
* @param {XYCoords} center - The center of the raster.
|
|
332
402
|
* @param {number} width - The total width of the raster (width/2 each to the left and to the right).
|
|
333
403
|
* @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).
|
|
334
404
|
* @param {number} sizeX - The horizontal raster size.
|
|
335
405
|
* @param {number} sizeY - The vertical raster size.
|
|
336
406
|
* @param {string} color - The CSS color to draw the raster with.
|
|
337
|
-
* @return {
|
|
407
|
+
* @return {R}
|
|
338
408
|
* @instance
|
|
339
409
|
* @memberof DrawLib
|
|
340
410
|
*/
|
|
341
|
-
raster: (center:
|
|
411
|
+
raster: (center: XYCoords, width: number, height: number, sizeX: number, sizeY: number, color: string) => R;
|
|
342
412
|
/**
|
|
343
413
|
* Draw a diamond handle (square rotated by 45°) with the given CSS color.
|
|
344
414
|
*
|
|
@@ -347,14 +417,14 @@ export interface DrawLib<R> {
|
|
|
347
417
|
* as even shaped diamonds.
|
|
348
418
|
*
|
|
349
419
|
* @method diamondHandle
|
|
350
|
-
* @param {
|
|
351
|
-
* @param {
|
|
420
|
+
* @param {XYCoords} center - The center of the diamond.
|
|
421
|
+
* @param {number} size - The x/y-size of the diamond.
|
|
352
422
|
* @param {string} color - The CSS color to draw the diamond with.
|
|
353
|
-
* @return {
|
|
423
|
+
* @return {R}
|
|
354
424
|
* @instance
|
|
355
425
|
* @memberof DrawLib
|
|
356
426
|
*/
|
|
357
|
-
diamondHandle: (center:
|
|
427
|
+
diamondHandle: (center: XYCoords, size: number, color: string) => R;
|
|
358
428
|
/**
|
|
359
429
|
* Draw a square handle with the given CSS color.<br>
|
|
360
430
|
* <br>
|
|
@@ -363,14 +433,14 @@ export interface DrawLib<R> {
|
|
|
363
433
|
* as even shaped squares.
|
|
364
434
|
*
|
|
365
435
|
* @method squareHandle
|
|
366
|
-
* @param {
|
|
367
|
-
* @param {
|
|
436
|
+
* @param {XYCoords} center - The center of the square.
|
|
437
|
+
* @param {number} size - The x/y-size of the square.
|
|
368
438
|
* @param {string} color - The CSS color to draw the square with.
|
|
369
|
-
* @return {
|
|
439
|
+
* @return {R}
|
|
370
440
|
* @instance
|
|
371
441
|
* @memberof DrawLib
|
|
372
442
|
*/
|
|
373
|
-
squareHandle: (center:
|
|
443
|
+
squareHandle: (center: XYCoords, size: number, color: string) => R;
|
|
374
444
|
/**
|
|
375
445
|
* Draw a circle handle with the given CSS color.<br>
|
|
376
446
|
* <br>
|
|
@@ -379,14 +449,14 @@ export interface DrawLib<R> {
|
|
|
379
449
|
* as even shaped circles.
|
|
380
450
|
*
|
|
381
451
|
* @method circleHandle
|
|
382
|
-
* @param {
|
|
452
|
+
* @param {XYCoords} center - The center of the circle.
|
|
383
453
|
* @param {number} radius - The radius of the circle.
|
|
384
454
|
* @param {string} color - The CSS color to draw the circle with.
|
|
385
|
-
* @return {
|
|
455
|
+
* @return {R}
|
|
386
456
|
* @instance
|
|
387
457
|
* @memberof DrawLib
|
|
388
458
|
*/
|
|
389
|
-
circleHandle: (center:
|
|
459
|
+
circleHandle: (center: XYCoords, size: number, color: string) => R;
|
|
390
460
|
/**
|
|
391
461
|
* Draw a crosshair with given radius and color at the given position.<br>
|
|
392
462
|
* <br>
|
|
@@ -397,7 +467,7 @@ export interface DrawLib<R> {
|
|
|
397
467
|
* @param {number} radius - The radius of the crosshair.
|
|
398
468
|
* @param {string} color - The CSS color to draw the crosshair with.
|
|
399
469
|
* @param {number=0.5} lineWidth - (optional, default=0.5) The line width to use.
|
|
400
|
-
* @return {
|
|
470
|
+
* @return {R}
|
|
401
471
|
* @instance
|
|
402
472
|
* @memberof DrawLib
|
|
403
473
|
*/
|
|
@@ -412,7 +482,7 @@ export interface DrawLib<R> {
|
|
|
412
482
|
* @param {number} radius - The radius of the crosshair.
|
|
413
483
|
* @param {string} color - The CSS color to draw the crosshair with.
|
|
414
484
|
* @param {number=1} lineWidth - (optional, default=1.0) The line width to use.
|
|
415
|
-
* @return {
|
|
485
|
+
* @return {R}
|
|
416
486
|
* @instance
|
|
417
487
|
* @memberof DrawLib
|
|
418
488
|
*/
|
|
@@ -423,24 +493,29 @@ export interface DrawLib<R> {
|
|
|
423
493
|
* @method polygon
|
|
424
494
|
* @param {Polygon} polygon - The polygon to draw.
|
|
425
495
|
* @param {string} color - The CSS color to draw the polygon with.
|
|
426
|
-
* @
|
|
496
|
+
* @param {number=} lineWidth - The line width to draw this polygon with.
|
|
497
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
498
|
+
*
|
|
499
|
+
* @return {R}
|
|
427
500
|
* @instance
|
|
428
501
|
* @memberof DrawLib
|
|
429
502
|
*/
|
|
430
|
-
polygon: (polygon: Polygon, color: string, lineWidth?: number) => R;
|
|
503
|
+
polygon: (polygon: Polygon, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
431
504
|
/**
|
|
432
505
|
* Draw a polygon line (alternative function to the polygon).
|
|
433
506
|
*
|
|
434
507
|
* @method polyline
|
|
435
|
-
* @param {
|
|
508
|
+
* @param {XYCoords[]} vertices - The polygon vertices to draw.
|
|
436
509
|
* @param {boolan} isOpen - If true the polyline will not be closed at its end.
|
|
437
510
|
* @param {string} color - The CSS color to draw the polygon with.
|
|
438
511
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
439
|
-
* @
|
|
512
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
513
|
+
*
|
|
514
|
+
* @return {R}
|
|
440
515
|
* @instance
|
|
441
516
|
* @memberof DrawLib
|
|
442
517
|
*/
|
|
443
|
-
polyline: (vertices: Array<
|
|
518
|
+
polyline: (vertices: Array<XYCoords>, isOpen: boolean, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) => R;
|
|
444
519
|
/**
|
|
445
520
|
* Draw a text at the given relative position.
|
|
446
521
|
*
|
|
@@ -483,13 +558,16 @@ export interface DrawLib<R> {
|
|
|
483
558
|
* @param {string=null} color - (optional) The color to draw this path with (default is null).
|
|
484
559
|
* @param {number=1} lineWidth - (optional) the line width to use (default is 1).
|
|
485
560
|
* @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.
|
|
561
|
+
* @param {number=} options.dashOffset - See `StrokeOptions`.
|
|
562
|
+
* @param {number[]=} options.dashArray - See `StrokeOptions`.
|
|
563
|
+
*
|
|
486
564
|
* @instance
|
|
487
565
|
* @memberof DrawLib
|
|
488
566
|
* @return {R} An instance representing the drawn path.
|
|
489
567
|
*/
|
|
490
568
|
path: (pathData: SVGPathParams, color?: string, lineWidth?: number, options?: {
|
|
491
569
|
inplace?: boolean;
|
|
492
|
-
}) => R;
|
|
570
|
+
} & StrokeOptions) => R;
|
|
493
571
|
/**
|
|
494
572
|
* Due to gl compatibility there is a generic 'clear' function required
|
|
495
573
|
* to avoid accessing the context object itself directly.
|
|
@@ -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
|
export {};
|
|
24
30
|
//# sourceMappingURL=DrawLib.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawLib.js","sourceRoot":"","sources":["../../ts/interfaces/DrawLib.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"DrawLib.js","sourceRoot":"","sources":["../../ts/interfaces/DrawLib.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BI"}
|
|
@@ -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
|
import { Vertex } from "../Vertex";
|
|
23
24
|
import { Vector } from "../Vector";
|
|
@@ -63,6 +64,16 @@ export interface IBounds {
|
|
|
63
64
|
min: XYCoords;
|
|
64
65
|
max: XYCoords;
|
|
65
66
|
getCenter(): Vertex;
|
|
67
|
+
/**
|
|
68
|
+
* Generate a random point inside this bounds object. Safe areas at the border to avoid
|
|
69
|
+
* included.
|
|
70
|
+
*
|
|
71
|
+
* @method randomPoint
|
|
72
|
+
* @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.
|
|
73
|
+
* @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
|
|
74
|
+
* @returns {Vertex} A pseudo random point inside these bounds.
|
|
75
|
+
*/
|
|
76
|
+
randomPoint: (horizontalSafeArea?: number, verticalSafeArea?: number) => Vertex;
|
|
66
77
|
}
|
|
67
78
|
/**
|
|
68
79
|
* The types that can be drawn and thus added to the draw queue.
|
|
@@ -82,8 +93,8 @@ export interface CanvasWrapper {
|
|
|
82
93
|
/**
|
|
83
94
|
* The config that's used by PB.
|
|
84
95
|
*/
|
|
85
|
-
export interface Config {
|
|
86
|
-
canvas: HTMLCanvasElement | string;
|
|
96
|
+
export interface Config extends Record<string, boolean | number | string | Function | HTMLCanvasElement | SVGElement | undefined> {
|
|
97
|
+
canvas: HTMLCanvasElement | SVGElement | string;
|
|
87
98
|
fullSize: boolean;
|
|
88
99
|
fitToParent: boolean;
|
|
89
100
|
scaleX: number;
|
|
@@ -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
|
export {};
|
|
23
24
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../ts/interfaces/core.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../ts/interfaces/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;IAqBI"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export declare const detectDarkMode: (GUP?: Record<string, string>) => boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
export const detectDarkMode = (GUP) => {
|
|
11
|
+
// Respect overrides
|
|
12
|
+
if (typeof GUP !== "undefined" && GUP.hasOwnProperty("darkmode") && GUP["darkmode"]) {
|
|
13
|
+
// const overrideValue = PlotBoilerplate.utils.fetch.bool(GUP, "darkmode", null);
|
|
14
|
+
const overrideValue = !!JSON.parse(GUP["darkmode"]);
|
|
15
|
+
if (overrideValue !== null) {
|
|
16
|
+
return overrideValue;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (globalThis.matchMedia && globalThis.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
20
|
+
// dark mode by system
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
// else: dark mode by daytime
|
|
24
|
+
const hours = new Date().getHours();
|
|
25
|
+
const isDayTime = hours > 6 && hours < 18;
|
|
26
|
+
return !isDayTime;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=detectDarkMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectDarkMode.js","sourceRoot":"","sources":["../../ts/utils/detectDarkMode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAA4B,EAAE,EAAE;IAC7D,oBAAoB;IACpB,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,EAAE;QACnF,iFAAiF;QACjF,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;QACpD,IAAI,aAAa,KAAK,IAAI,EAAE;YAC1B,OAAO,aAAa,CAAC;SACtB;KACF;IACD,IAAI,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC,OAAO,EAAE;QAC1F,sBAAsB;QACtB,OAAO,IAAI,CAAC;KACb;IACD,6BAA6B;IAC7B,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC;IACpC,MAAM,SAAS,GAAG,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;IAC1C,OAAO,CAAC,SAAS,CAAC;AACpB,CAAC,CAAC"}
|