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.
Files changed (127) hide show
  1. package/dist/index.esm.js +1985 -1368
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.esm.min.js +1 -1
  4. package/dist/index.esm.min.js.map +1 -1
  5. package/dist/plotboilerplate.browser.min.js +1 -1
  6. package/dist/plotboilerplate.browser.min.js.map +1 -1
  7. package/dist/plotboilerplate.js +1170 -541
  8. package/dist/plotboilerplate.min.js +1 -1
  9. package/package.json +1 -1
  10. package/src/cjs/BezierPath.d.ts +27 -49
  11. package/src/cjs/BezierPath.js +67 -234
  12. package/src/cjs/BezierPath.js.map +1 -1
  13. package/src/cjs/Bounds.d.ts +14 -1
  14. package/src/cjs/Bounds.js +21 -1
  15. package/src/cjs/Bounds.js.map +1 -1
  16. package/src/cjs/CubicBezierCurve.d.ts +70 -1
  17. package/src/cjs/CubicBezierCurve.js +130 -12
  18. package/src/cjs/CubicBezierCurve.js.map +1 -1
  19. package/src/cjs/Line.d.ts +2 -1
  20. package/src/cjs/Line.js +1 -0
  21. package/src/cjs/Line.js.map +1 -1
  22. package/src/cjs/PBText.d.ts +2 -1
  23. package/src/cjs/PBText.js +10 -9
  24. package/src/cjs/PBText.js.map +1 -1
  25. package/src/cjs/PlotBoilerplate.d.ts +4 -13
  26. package/src/cjs/PlotBoilerplate.js +61 -15
  27. package/src/cjs/PlotBoilerplate.js.map +1 -1
  28. package/src/cjs/Polygon.d.ts +35 -1
  29. package/src/cjs/Polygon.js +87 -1
  30. package/src/cjs/Polygon.js.map +1 -1
  31. package/src/cjs/VEllipse.js +1 -1
  32. package/src/cjs/VEllipse.js.map +1 -1
  33. package/src/cjs/Vector.d.ts +4 -4
  34. package/src/cjs/Vector.js +2 -2
  35. package/src/cjs/Vector.js.map +1 -1
  36. package/src/cjs/VertTuple.d.ts +2 -1
  37. package/src/cjs/VertTuple.js +4 -3
  38. package/src/cjs/VertTuple.js.map +1 -1
  39. package/src/cjs/Vertex.d.ts +14 -3
  40. package/src/cjs/Vertex.js +18 -3
  41. package/src/cjs/Vertex.js.map +1 -1
  42. package/src/cjs/draw.d.ts +154 -75
  43. package/src/cjs/draw.js +308 -137
  44. package/src/cjs/draw.js.map +1 -1
  45. package/src/cjs/drawgl.d.ts +87 -50
  46. package/src/cjs/drawgl.js +86 -31
  47. package/src/cjs/drawgl.js.map +1 -1
  48. package/src/cjs/drawutilssvg.d.ts +226 -53
  49. package/src/cjs/drawutilssvg.js +374 -92
  50. package/src/cjs/drawutilssvg.js.map +1 -1
  51. package/src/cjs/interfaces/DrawLib.d.ts +157 -79
  52. package/src/cjs/interfaces/DrawLib.js +6 -0
  53. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  54. package/src/cjs/interfaces/core.d.ts +13 -2
  55. package/src/cjs/interfaces/core.js +1 -0
  56. package/src/cjs/interfaces/core.js.map +1 -1
  57. package/src/cjs/utils/creategui.js +16 -10
  58. package/src/cjs/utils/detectDarkMode.d.ts +10 -0
  59. package/src/cjs/utils/detectDarkMode.js +32 -0
  60. package/src/cjs/utils/detectDarkMode.js.map +1 -0
  61. package/src/esm/BezierPath.d.ts +27 -49
  62. package/src/esm/BezierPath.js +67 -234
  63. package/src/esm/BezierPath.js.map +1 -1
  64. package/src/esm/Bounds.d.ts +14 -1
  65. package/src/esm/Bounds.js +19 -1
  66. package/src/esm/Bounds.js.map +1 -1
  67. package/src/esm/CubicBezierCurve.d.ts +70 -1
  68. package/src/esm/CubicBezierCurve.js +130 -12
  69. package/src/esm/CubicBezierCurve.js.map +1 -1
  70. package/src/esm/Line.d.ts +2 -1
  71. package/src/esm/Line.js +1 -0
  72. package/src/esm/Line.js.map +1 -1
  73. package/src/esm/PBText.d.ts +2 -1
  74. package/src/esm/PBText.js +10 -9
  75. package/src/esm/PBText.js.map +1 -1
  76. package/src/esm/PlotBoilerplate.d.ts +4 -13
  77. package/src/esm/PlotBoilerplate.js +62 -16
  78. package/src/esm/PlotBoilerplate.js.map +1 -1
  79. package/src/esm/Polygon.d.ts +35 -1
  80. package/src/esm/Polygon.js +85 -1
  81. package/src/esm/Polygon.js.map +1 -1
  82. package/src/esm/VEllipse.js +1 -1
  83. package/src/esm/VEllipse.js.map +1 -1
  84. package/src/esm/Vector.d.ts +4 -4
  85. package/src/esm/Vector.js +2 -2
  86. package/src/esm/Vector.js.map +1 -1
  87. package/src/esm/VertTuple.d.ts +2 -1
  88. package/src/esm/VertTuple.js +4 -3
  89. package/src/esm/VertTuple.js.map +1 -1
  90. package/src/esm/Vertex.d.ts +14 -3
  91. package/src/esm/Vertex.js +18 -3
  92. package/src/esm/Vertex.js.map +1 -1
  93. package/src/esm/draw.d.ts +154 -75
  94. package/src/esm/draw.js +304 -135
  95. package/src/esm/draw.js.map +1 -1
  96. package/src/esm/drawgl.d.ts +87 -50
  97. package/src/esm/drawgl.js +86 -31
  98. package/src/esm/drawgl.js.map +1 -1
  99. package/src/esm/drawutilssvg.d.ts +226 -53
  100. package/src/esm/drawutilssvg.js +369 -92
  101. package/src/esm/drawutilssvg.js.map +1 -1
  102. package/src/esm/interfaces/DrawLib.d.ts +157 -79
  103. package/src/esm/interfaces/DrawLib.js +6 -0
  104. package/src/esm/interfaces/DrawLib.js.map +1 -1
  105. package/src/esm/interfaces/core.d.ts +13 -2
  106. package/src/esm/interfaces/core.js +1 -0
  107. package/src/esm/interfaces/core.js.map +1 -1
  108. package/src/esm/utils/detectDarkMode.d.ts +10 -0
  109. package/src/esm/utils/detectDarkMode.js +28 -0
  110. package/src/esm/utils/detectDarkMode.js.map +1 -0
  111. package/src/ts/BezierPath.ts +72 -241
  112. package/src/ts/Bounds.ts +25 -1
  113. package/src/ts/CubicBezierCurve.ts +139 -12
  114. package/src/ts/Line.ts +2 -1
  115. package/src/ts/PBText.ts +10 -9
  116. package/src/ts/PlotBoilerplate.ts +56 -19
  117. package/src/ts/Polygon.ts +91 -1
  118. package/src/ts/VEllipse.ts +2 -2
  119. package/src/ts/Vector.ts +4 -4
  120. package/src/ts/VertTuple.ts +4 -3
  121. package/src/ts/Vertex.ts +20 -4
  122. package/src/ts/draw.ts +311 -115
  123. package/src/ts/drawgl.ts +133 -71
  124. package/src/ts/drawutilssvg.ts +543 -121
  125. package/src/ts/interfaces/DrawLib.ts +219 -83
  126. package/src/ts/interfaces/core.ts +14 -2
  127. package/src/ts/utils/detectDarkMode.ts +30 -0
package/src/ts/drawgl.ts CHANGED
@@ -11,22 +11,17 @@
11
11
  * @modified 2022-03-27 Added the `texturedPoly` function.
12
12
  * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
13
13
  * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.
14
- * @version 0.0.9
14
+ * @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.
15
+ * @modified 2023-09-29 Added the `headLength` parameter to the 'DrawLib.arrow()` function.
16
+ * @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface.
17
+ * @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
18
+ * @modified 2023-09-29 Added the `lineDashes` attribute.
19
+ * @version 0.0.10
15
20
  **/
16
21
 
17
- import { CubicBezierCurve } from "./CubicBezierCurve";
18
22
  import { Polygon } from "./Polygon";
19
23
  import { Vertex } from "./Vertex";
20
- import {
21
- DrawLib,
22
- XYCoords,
23
- SVGPathParams,
24
- SVGSerializable,
25
- UID,
26
- DrawLibConfiguration,
27
- FontStyle,
28
- FontWeight
29
- } from "./interfaces";
24
+ import { DrawLib, XYCoords, SVGPathParams, UID, DrawLibConfiguration, FontStyle, FontWeight } from "./interfaces";
30
25
  import { Bounds } from "./Bounds";
31
26
 
32
27
  /**
@@ -110,8 +105,8 @@ export class drawutilsgl implements DrawLib<void> {
110
105
  // This needs to be considered in the overlying component; both draw-instances need to
111
106
  // share their gl context.
112
107
  // That's what the copyInstace(boolean) method is good for.
113
- this._vertShader = this.glutils.compileShader(drawutilsgl.vertCode, this.gl.VERTEX_SHADER);
114
- this._fragShader = this.glutils.compileShader(drawutilsgl.fragCode, this.gl.FRAGMENT_SHADER);
108
+ this._vertShader = this.glutils.compileShader(drawutilsgl.vertCode, this.gl.VERTEX_SHADER) as WebGLShader;
109
+ this._fragShader = this.glutils.compileShader(drawutilsgl.fragCode, this.gl.FRAGMENT_SHADER) as WebGLShader;
115
110
  this._program = this.glutils.makeProgram(this._vertShader, this._fragShader);
116
111
 
117
112
  // Create an empty buffer object
@@ -134,7 +129,7 @@ export class drawutilsgl implements DrawLib<void> {
134
129
  * that under the hood the same gl context and gl program will be used.
135
130
  */
136
131
  copyInstance(fillShapes: boolean): drawutilsgl {
137
- var copy: drawutilsgl = new drawutilsgl(null, fillShapes);
132
+ var copy: drawutilsgl = new drawutilsgl(null as any as WebGLRenderingContext, fillShapes);
138
133
  copy.gl = this.gl;
139
134
  copy.glutils = this.glutils;
140
135
  copy._vertShader = this._vertShader;
@@ -177,6 +172,21 @@ export class drawutilsgl implements DrawLib<void> {
177
172
  // TODO
178
173
  }
179
174
 
175
+ // /**
176
+ // * Set or clear the line-dash configuration. Pass `null` for un-dashed lines.
177
+ // *
178
+ // * See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
179
+ // * and https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
180
+ // * for how line dashes work.
181
+ // *
182
+ // * @method
183
+ // * @param {Array<number> lineDashes - The line-dash array configuration.
184
+ // * @returns {void}
185
+ // */
186
+ // setLineDash(lineDashes: Array<number>) {
187
+ // // TODO
188
+ // }
189
+
180
190
  /**
181
191
  * This method shouled be called each time the currently drawn `Drawable` changes.
182
192
  * It is used by some libraries for identifying elemente on re-renders.
@@ -206,14 +216,14 @@ export class drawutilsgl implements DrawLib<void> {
206
216
  * Draw the line between the given two points with the specified (CSS-) color.
207
217
  *
208
218
  * @method line
209
- * @param {Vertex} zA - The start point of the line.
210
- * @param {Vertex} zB - The end point of the line.
219
+ * @param {XYCoords} zA - The start point of the line.
220
+ * @param {XYCoords} zB - The end point of the line.
211
221
  * @param {string} color - Any valid CSS color string.
212
222
  * @return {void}
213
223
  * @instance
214
224
  * @memberof drawutils
215
225
  **/
216
- line(zA: Vertex, zB: Vertex, color: string) {
226
+ line(zA: XYCoords, zB: XYCoords, color: string) {
217
227
  const vertices: Float32Array = new Float32Array(6);
218
228
  vertices[0] = this._x2rel(zA.x);
219
229
  vertices[1] = this._y2rel(zA.y);
@@ -261,14 +271,60 @@ export class drawutilsgl implements DrawLib<void> {
261
271
  * Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.
262
272
  *
263
273
  * @method arrow
264
- * @param {Vertex} zA - The start point of the arrow-line.
265
- * @param {Vertex} zB - The end point of the arrow-line.
274
+ * @param {XYCoords} zA - The start point of the arrow-line.
275
+ * @param {XYCoords} zB - The end point of the arrow-line.
266
276
  * @param {string} color - Any valid CSS color string.
277
+ * @param {headLength=8} headLength - (optional) The length of the arrow head (default is 8 units).
267
278
  * @return {void}
268
279
  * @instance
269
280
  * @memberof drawutils
270
281
  **/
271
- arrow(zA: Vertex, zB: Vertex, color: string) {
282
+ arrow(zA: XYCoords, zB: XYCoords, color: string) {
283
+ // NOT YET IMPLEMENTED
284
+ }
285
+
286
+ /**
287
+ * 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.
288
+ *
289
+ * @method cubicBezierArrow
290
+ * @param {XYCoords} startPoint - The start point of the cubic Bézier curve
291
+ * @param {XYCoords} endPoint - The end point the cubic Bézier curve.
292
+ * @param {XYCoords} startControlPoint - The start control point the cubic Bézier curve.
293
+ * @param {XYCoords} endControlPoint - The end control point the cubic Bézier curve.
294
+ * @param {string} color - The CSS color to draw the curve with.
295
+ * @param {number} lineWidth - (optional) The line width to use.
296
+ * @param {headLength=8} headLength - (optional) The length of the arrow head (default is 8 units).
297
+ *
298
+ * @return {void}
299
+ * @instance
300
+ * @memberof DrawLib
301
+ */
302
+ cubicBezierArrow(
303
+ startPoint: XYCoords,
304
+ endPoint: XYCoords,
305
+ startControlPoint: XYCoords,
306
+ endControlPoint: XYCoords,
307
+ color: string,
308
+ lineWidth?: number,
309
+ headLength?: number
310
+ ) {
311
+ // NOT YET IMPLEMENTED
312
+ }
313
+
314
+ /**
315
+ * Draw just an arrow head a the end of an imaginary line (zB) of the given line width the specified (CSS-) color and size.
316
+ *
317
+ * @method arrow
318
+ * @param {XYCoords} zA - The start point of the arrow-line.
319
+ * @param {XYCoords} zB - The end point of the arrow-line.
320
+ * @param {string} color - Any valid CSS color string.
321
+ * @param {number=1} lineWidth - (optional) The line width to use; default is 1.
322
+ * @param {number=8} headLength - (optional) The length of the arrow head (default is 8 pixels).
323
+ * @return {void}
324
+ * @instance
325
+ * @memberof DrawLib
326
+ **/
327
+ arrowHead(zA: XYCoords, zB: XYCoords, color: string, lineWidth?: number, headLength?: number) {
272
328
  // NOT YET IMPLEMENTED
273
329
  }
274
330
 
@@ -279,14 +335,14 @@ export class drawutilsgl implements DrawLib<void> {
279
335
  *
280
336
  * @method image
281
337
  * @param {Image} image - The image object to draw.
282
- * @param {Vertex} position - The position to draw the the upper left corner at.
283
- * @param {Vertex} size - The x/y-size to draw the image with.
338
+ * @param {XYCoords} position - The position to draw the the upper left corner at.
339
+ * @param {XYCoords} size - The x/y-size to draw the image with.
284
340
  * @param {number=0.0} alpha - (optional, default=0.0) The transparency (0.0=opaque, 1.0=transparent).
285
341
  * @return {void}
286
342
  * @instance
287
343
  * @memberof drawutils
288
344
  **/
289
- image(image: HTMLImageElement, position: Vertex, size: Vertex, alpha: number = 0.0) {
345
+ image(image: HTMLImageElement, position: XYCoords, size: XYCoords, alpha: number = 0.0) {
290
346
  // NOT YET IMPLEMENTED
291
347
  }
292
348
 
@@ -299,13 +355,19 @@ export class drawutilsgl implements DrawLib<void> {
299
355
  * @param {Image} textureImage - The image object to draw.
300
356
  * @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.
301
357
  * @param {Polygon} polygon - The polygon to use as clip path.
302
- * @param {Vertex} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
358
+ * @param {XYCoords} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
303
359
  * @param {number} rotation - The rotation to use for the polygon (and for the texture).
304
360
  * @return {void}
305
361
  * @instance
306
362
  * @memberof drawutilsgl
307
363
  **/
308
- texturedPoly(textureImage: HTMLImageElement, textureSize: Bounds, polygon: Polygon, polygonPosition: Vertex, rotation: number) {
364
+ texturedPoly(
365
+ textureImage: HTMLImageElement,
366
+ textureSize: Bounds,
367
+ polygon: Polygon,
368
+ polygonPosition: XYCoords,
369
+ rotation: number
370
+ ) {
309
371
  // NOT YET IMPLEMENTED
310
372
  }
311
373
 
@@ -328,10 +390,10 @@ export class drawutilsgl implements DrawLib<void> {
328
390
  * Draw the given (cubic) bézier curve.
329
391
  *
330
392
  * @method cubicBezier
331
- * @param {Vertex} startPoint - The start point of the cubic Bézier curve
332
- * @param {Vertex} endPoint - The end point the cubic Bézier curve.
333
- * @param {Vertex} startControlPoint - The start control point the cubic Bézier curve.
334
- * @param {Vertex} endControlPoint - The end control point the cubic Bézier curve.
393
+ * @param {XYCoords} startPoint - The start point of the cubic Bézier curve
394
+ * @param {XYCoords} endPoint - The end point the cubic Bézier curve.
395
+ * @param {XYCoords} startControlPoint - The start control point the cubic Bézier curve.
396
+ * @param {VertXYCoordsex} endControlPoint - The end control point the cubic Bézier curve.
335
397
  * @param {string} color - The CSS color to draw the curve with.
336
398
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
337
399
  * @return {void}
@@ -339,10 +401,10 @@ export class drawutilsgl implements DrawLib<void> {
339
401
  * @memberof drawutils
340
402
  */
341
403
  cubicBezier(
342
- startPoint: Vertex,
343
- endPoint: Vertex,
344
- startControlPoint: Vertex,
345
- endControlPoint: Vertex,
404
+ startPoint: XYCoords,
405
+ endPoint: XYCoords,
406
+ startControlPoint: XYCoords,
407
+ endControlPoint: XYCoords,
346
408
  color: string,
347
409
  lineWidth?: number
348
410
  ) {
@@ -357,14 +419,14 @@ export class drawutilsgl implements DrawLib<void> {
357
419
  * <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>
358
420
  *
359
421
  * @method cubicBezierPath
360
- * @param {Vertex[]} path - The cubic bezier path as described above.
422
+ * @param {XYCoords[]} path - The cubic bezier path as described above.
361
423
  * @param {string} color - The CSS colot to draw the path with.
362
424
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
363
425
  * @return {void}
364
426
  * @instance
365
427
  * @memberof drawutils
366
428
  */
367
- cubicBezierPath(path: Array<Vertex>, color: string, lineWidth?: number) {
429
+ cubicBezierPath(path: Array<XYCoords>, color: string, lineWidth?: number) {
368
430
  // NOT YET IMPLEMENTED
369
431
  }
370
432
 
@@ -374,13 +436,13 @@ export class drawutilsgl implements DrawLib<void> {
374
436
  * The colors for this are fixed and cannot be specified.
375
437
  *
376
438
  * @method handle
377
- * @param {Vertex} startPoint - The start of the handle.
378
- * @param {Vertex} endPoint - The end point of the handle.
439
+ * @param {XYCoords} startPoint - The start of the handle.
440
+ * @param {XYCoords} endPoint - The end point of the handle.
379
441
  * @return {void}
380
442
  * @instance
381
443
  * @memberof drawutils
382
444
  */
383
- handle(startPoint: Vertex, endPoint: Vertex) {
445
+ handle(startPoint: XYCoords, endPoint: XYCoords) {
384
446
  // NOT YET IMPLEMENTED
385
447
  }
386
448
 
@@ -388,13 +450,13 @@ export class drawutilsgl implements DrawLib<void> {
388
450
  * Draw a handle line (with a light grey).
389
451
  *
390
452
  * @method handleLine
391
- * @param {Vertex} startPoint - The start point to draw the handle at.
392
- * @param {Vertex} endPoint - The end point to draw the handle at.
453
+ * @param {XYCoords} startPoint - The start point to draw the handle at.
454
+ * @param {XYCoords} endPoint - The end point to draw the handle at.
393
455
  * @return {void}
394
456
  * @instance
395
457
  * @memberof drawutils
396
458
  */
397
- handleLine(startPoint: Vertex, endPoint: Vertex) {
459
+ handleLine(startPoint: XYCoords, endPoint: XYCoords) {
398
460
  // NOT YET IMPLEMENTED
399
461
  }
400
462
 
@@ -402,13 +464,13 @@ export class drawutilsgl implements DrawLib<void> {
402
464
  * Draw a 1x1 dot with the specified (CSS-) color.
403
465
  *
404
466
  * @method dot
405
- * @param {Vertex} p - The position to draw the dot at.
467
+ * @param {XYCoords} p - The position to draw the dot at.
406
468
  * @param {string} color - The CSS color to draw the dot with.
407
469
  * @return {void}
408
470
  * @instance
409
471
  * @memberof drawutils
410
472
  */
411
- dot(p: Vertex, color: string) {
473
+ dot(p: XYCoords, color: string) {
412
474
  // NOT YET IMPLEMENTED
413
475
  }
414
476
 
@@ -416,13 +478,13 @@ export class drawutilsgl implements DrawLib<void> {
416
478
  * Draw the given point with the specified (CSS-) color and radius 3.
417
479
  *
418
480
  * @method point
419
- * @param {Vertex} p - The position to draw the point at.
481
+ * @param {XYCoords} p - The position to draw the point at.
420
482
  * @param {string} color - The CSS color to draw the point with.
421
483
  * @return {void}
422
484
  * @instance
423
485
  * @memberof drawutils
424
486
  */
425
- point(p: Vertex, color: string) {
487
+ point(p: XYCoords, color: string) {
426
488
  // NOT YET IMPLEMENTED
427
489
  }
428
490
 
@@ -432,7 +494,7 @@ export class drawutilsgl implements DrawLib<void> {
432
494
  * Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.
433
495
  *
434
496
  * @method circle
435
- * @param {Vertex} center - The center of the circle.
497
+ * @param {XYCoords} center - The center of the circle.
436
498
  * @param {number} radius - The radius of the circle.
437
499
  * @param {string} color - The CSS color to draw the circle with.
438
500
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
@@ -440,7 +502,7 @@ export class drawutilsgl implements DrawLib<void> {
440
502
  * @instance
441
503
  * @memberof drawutils
442
504
  */
443
- circle(center: Vertex, radius: number, color: string, lineWidth?: number) {
505
+ circle(center: XYCoords, radius: number, color: string, lineWidth?: number) {
444
506
  // NOT YET IMPLEMENTED
445
507
  }
446
508
 
@@ -448,7 +510,7 @@ export class drawutilsgl implements DrawLib<void> {
448
510
  * Draw a circular arc (section of a circle) with the given CSS color.
449
511
  *
450
512
  * @method circleArc
451
- * @param {Vertex} center - The center of the circle.
513
+ * @param {XYCoords} center - The center of the circle.
452
514
  * @param {number} radius - The radius of the circle.
453
515
  * @param {number} startAngle - The angle to start at.
454
516
  * @param {number} endAngle - The angle to end at.
@@ -457,7 +519,7 @@ export class drawutilsgl implements DrawLib<void> {
457
519
  * @instance
458
520
  * @memberof drawutils
459
521
  */
460
- circleArc(center: Vertex, radius: number, startAngle: number, endAngle: number, color: string, lineWidth?: number) {
522
+ circleArc(center: XYCoords, radius: number, startAngle: number, endAngle: number, color: string, lineWidth?: number) {
461
523
  // NOT YET IMPLEMENTED
462
524
  }
463
525
 
@@ -465,7 +527,7 @@ export class drawutilsgl implements DrawLib<void> {
465
527
  * Draw an ellipse with the specified (CSS-) color and thw two radii.
466
528
  *
467
529
  * @method ellipse
468
- * @param {Vertex} center - The center of the ellipse.
530
+ * @param {XYCoords} center - The center of the ellipse.
469
531
  * @param {number} radiusX - The radius of the ellipse.
470
532
  * @param {number} radiusY - The radius of the ellipse.
471
533
  * @param {string} color - The CSS color to draw the ellipse with.
@@ -475,7 +537,7 @@ export class drawutilsgl implements DrawLib<void> {
475
537
  * @instance
476
538
  * @memberof drawutils
477
539
  */
478
- ellipse(center: Vertex, radiusX: number, radiusY: number, color: string, lineWidth?: number, rotation?: number) {
540
+ ellipse(center: XYCoords, radiusX: number, radiusY: number, color: string, lineWidth?: number, rotation?: number) {
479
541
  // NOT YET IMPLEMENTED
480
542
  }
481
543
 
@@ -486,7 +548,7 @@ export class drawutilsgl implements DrawLib<void> {
486
548
  *
487
549
  * @method square
488
550
  * @param {XYCords} center - The center of the square.
489
- * @param {Vertex} size - The size of the square.
551
+ * @param {number} size - The size of the square.
490
552
  * @param {string} color - The CSS color to draw the square with.
491
553
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
492
554
  * @return {void}
@@ -514,7 +576,7 @@ export class drawutilsgl implements DrawLib<void> {
514
576
  * Draw a grid of horizontal and vertical lines with the given (CSS-) color.
515
577
  *
516
578
  * @method grid
517
- * @param {Vertex} center - The center of the grid.
579
+ * @param {XYCoords} center - The center of the grid.
518
580
  * @param {number} width - The total width of the grid (width/2 each to the left and to the right).
519
581
  * @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).
520
582
  * @param {number} sizeX - The horizontal grid size.
@@ -524,7 +586,7 @@ export class drawutilsgl implements DrawLib<void> {
524
586
  * @instance
525
587
  * @memberof drawutils
526
588
  */
527
- grid(center: Vertex, width: number, height: number, sizeX: number, sizeY: number, color: string) {
589
+ grid(center: XYCoords, width: number, height: number, sizeX: number, sizeY: number, color: string) {
528
590
  // NOT YET IMPLEMENTED
529
591
  }
530
592
 
@@ -534,7 +596,7 @@ export class drawutilsgl implements DrawLib<void> {
534
596
  * This works analogue to the grid() function
535
597
  *
536
598
  * @method raster
537
- * @param {Vertex} center - The center of the raster.
599
+ * @param {XYCoords} center - The center of the raster.
538
600
  * @param {number} width - The total width of the raster (width/2 each to the left and to the right).
539
601
  * @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).
540
602
  * @param {number} sizeX - The horizontal raster size.
@@ -544,7 +606,7 @@ export class drawutilsgl implements DrawLib<void> {
544
606
  * @instance
545
607
  * @memberof drawutils
546
608
  */
547
- raster(center: Vertex, width: number, height: number, sizeX: number, sizeY: number, color: string) {
609
+ raster(center: XYCoords, width: number, height: number, sizeX: number, sizeY: number, color: string) {
548
610
  // NOT YET IMPLEMENTED
549
611
  }
550
612
 
@@ -556,14 +618,14 @@ export class drawutilsgl implements DrawLib<void> {
556
618
  * as even shaped diamonds.
557
619
  *
558
620
  * @method diamondHandle
559
- * @param {Vertex} center - The center of the diamond.
560
- * @param {Vertex} size - The x/y-size of the diamond.
621
+ * @param {XYCoords} center - The center of the diamond.
622
+ * @param {number} size - The x/y-size of the diamond.
561
623
  * @param {string} color - The CSS color to draw the diamond with.
562
624
  * @return {void}
563
625
  * @instance
564
626
  * @memberof drawutils
565
627
  */
566
- diamondHandle(center: Vertex, size: number, color: string) {
628
+ diamondHandle(center: XYCoords, size: number, color: string) {
567
629
  // NOT YET IMPLEMENTED
568
630
  }
569
631
 
@@ -575,14 +637,14 @@ export class drawutilsgl implements DrawLib<void> {
575
637
  * as even shaped squares.
576
638
  *
577
639
  * @method squareHandle
578
- * @param {Vertex} center - The center of the square.
579
- * @param {Vertex} size - The x/y-size of the square.
640
+ * @param {XYCoords} center - The center of the square.
641
+ * @param {number} size - The x/y-size of the square.
580
642
  * @param {string} color - The CSS color to draw the square with.
581
643
  * @return {void}
582
644
  * @instance
583
645
  * @memberof drawutils
584
646
  */
585
- squareHandle(center: Vertex, size: number, color: string) {
647
+ squareHandle(center: XYCoords, size: number, color: string) {
586
648
  // NOT YET IMPLEMENTED
587
649
  }
588
650
 
@@ -594,14 +656,14 @@ export class drawutilsgl implements DrawLib<void> {
594
656
  * as even shaped circles.
595
657
  *
596
658
  * @method circleHandle
597
- * @param {Vertex} center - The center of the circle.
659
+ * @param {XYCoords} center - The center of the circle.
598
660
  * @param {number} radius - The radius of the circle.
599
661
  * @param {string} color - The CSS color to draw the circle with.
600
662
  * @return {void}
601
663
  * @instance
602
664
  * @memberof drawutils
603
665
  */
604
- circleHandle(center: Vertex, size: number, color: string) {
666
+ circleHandle(center: XYCoords, size: number, color: string) {
605
667
  // NOT YET IMPLEMENTED
606
668
  }
607
669
 
@@ -697,7 +759,7 @@ export class drawutilsgl implements DrawLib<void> {
697
759
  * Draw a polygon line (alternative function to the polygon).
698
760
  *
699
761
  * @method polyline
700
- * @param {Vertex[]} vertices - The polygon vertices to draw.
762
+ * @param {XYCoords[]} vertices - The polygon vertices to draw.
701
763
  * @param {boolan} isOpen - If true the polyline will not be closed at its end.
702
764
  * @param {string} color - The CSS color to draw the polygon with.
703
765
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
@@ -705,7 +767,7 @@ export class drawutilsgl implements DrawLib<void> {
705
767
  * @instance
706
768
  * @memberof drawutils
707
769
  */
708
- polyline(vertices: Array<Vertex>, isOpen: boolean, color: string, lineWidth?: number) {
770
+ polyline(vertices: Array<XYCoords>, isOpen: boolean, color: string, lineWidth?: number) {
709
771
  // NOT YET IMPLEMENTED
710
772
  }
711
773
 
@@ -816,7 +878,7 @@ class GLU {
816
878
 
817
879
  bufferData(verts: Float32Array): WebGLBuffer {
818
880
  // Create an empty buffer object
819
- var vbuffer: WebGLBuffer = this.gl.createBuffer();
881
+ var vbuffer: WebGLBuffer = this.gl.createBuffer() as WebGLBuffer;
820
882
  // Bind appropriate array buffer to it
821
883
  this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vbuffer);
822
884
  // Pass the vertex data to the buffer
@@ -827,9 +889,9 @@ class GLU {
827
889
  }
828
890
 
829
891
  /*=================== Shaders ====================*/
830
- compileShader(shaderCode: string, shaderType: any): WebGLShader {
892
+ compileShader(shaderCode: string, shaderType: any): WebGLShader | null {
831
893
  // Create a vertex shader object
832
- var shader: WebGLShader = this.gl.createShader(shaderType);
894
+ var shader: WebGLShader = this.gl.createShader(shaderType) as WebGLShader;
833
895
  // Attach vertex shader source code
834
896
  this.gl.shaderSource(shader, shaderCode);
835
897
  // Compile the vertex shader
@@ -846,7 +908,7 @@ class GLU {
846
908
  makeProgram(vertShader: WebGLShader, fragShader: WebGLShader): WebGLProgram {
847
909
  // Create a shader program object to store
848
910
  // the combined shader program
849
- var program: WebGLProgram = this.gl.createProgram();
911
+ var program: WebGLProgram = this.gl.createProgram() as WebGLProgram;
850
912
 
851
913
  // Attach a vertex shader
852
914
  this.gl.attachShader(program, vertShader);