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.
- package/README.md +17 -1
- package/dist/index.esm.js +2065 -1397
- 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 +1265 -584
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +2 -1
- package/src/cjs/BezierPath.d.ts +27 -49
- package/src/cjs/BezierPath.js +69 -237
- 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 +10 -13
- package/src/cjs/PlotBoilerplate.js +136 -47
- 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/Triangle.js +1 -0
- package/src/cjs/Triangle.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 +159 -79
- package/src/cjs/draw.js +311 -139
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.d.ts +93 -55
- package/src/cjs/drawgl.js +90 -34
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +233 -58
- package/src/cjs/drawutilssvg.js +384 -95
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +161 -82
- package/src/cjs/interfaces/DrawLib.js +7 -0
- package/src/cjs/interfaces/DrawLib.js.map +1 -1
- package/src/cjs/interfaces/core.d.ts +46 -32
- package/src/cjs/interfaces/core.js +2 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/creategui.js +16 -10
- package/src/cjs/utils/datastructures/Color.d.ts +3 -1
- package/src/cjs/utils/datastructures/Color.js +12 -1
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- 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/cjs/utils/module.js +4 -2
- package/src/esm/BezierPath.d.ts +27 -49
- package/src/esm/BezierPath.js +69 -237
- 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 +10 -13
- package/src/esm/PlotBoilerplate.js +136 -48
- 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/Triangle.js +1 -0
- package/src/esm/Triangle.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 +159 -79
- package/src/esm/draw.js +307 -137
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.d.ts +93 -55
- package/src/esm/drawgl.js +90 -34
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +233 -58
- package/src/esm/drawutilssvg.js +379 -95
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +161 -82
- package/src/esm/interfaces/DrawLib.js +7 -0
- package/src/esm/interfaces/DrawLib.js.map +1 -1
- package/src/esm/interfaces/core.d.ts +46 -32
- package/src/esm/interfaces/core.js +2 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/datastructures/Color.d.ts +3 -1
- package/src/esm/utils/datastructures/Color.js +12 -1
- package/src/esm/utils/datastructures/Color.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 +74 -244
- 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 +130 -50
- package/src/ts/Polygon.ts +91 -1
- package/src/ts/Triangle.ts +2 -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 +316 -119
- package/src/ts/drawgl.ts +141 -78
- package/src/ts/drawutilssvg.ts +562 -133
- package/src/ts/interfaces/DrawLib.ts +223 -86
- package/src/ts/interfaces/core.ts +47 -32
- package/src/ts/utils/datastructures/Color.ts +13 -1
- 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
|
-
* @
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 {
|
|
209
|
-
* @param {
|
|
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:
|
|
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 {
|
|
264
|
-
* @param {
|
|
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:
|
|
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 {
|
|
282
|
-
* @param {
|
|
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:
|
|
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 {
|
|
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(
|
|
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 {
|
|
331
|
-
* @param {
|
|
332
|
-
* @param {
|
|
333
|
-
* @param {
|
|
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:
|
|
342
|
-
endPoint:
|
|
343
|
-
startControlPoint:
|
|
344
|
-
endControlPoint:
|
|
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 {
|
|
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<
|
|
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 {
|
|
377
|
-
* @param {
|
|
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:
|
|
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 {
|
|
391
|
-
* @param {
|
|
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:
|
|
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 {
|
|
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:
|
|
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 {
|
|
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:
|
|
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 {
|
|
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:
|
|
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 {
|
|
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:
|
|
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 {
|
|
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:
|
|
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 {
|
|
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 {
|
|
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:
|
|
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 {
|
|
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:
|
|
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 {
|
|
559
|
-
* @param {
|
|
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:
|
|
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 {
|
|
578
|
-
* @param {
|
|
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:
|
|
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 {
|
|
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:
|
|
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 {
|
|
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<
|
|
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);
|