plotboilerplate 1.20.1 → 1.21.0

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