Skip to content

Commit d509180

Browse files
committed
v0.5.4
1 parent 4f4b2cc commit d509180

File tree

10 files changed

+323
-211
lines changed

10 files changed

+323
-211
lines changed

dist/WebglBaseLine.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ export declare class WebglBaseLine {
2424
*/
2525
scaleX: number;
2626
/**
27-
* The vertical sclae of the line
27+
* The vertical scale of the line
2828
* @default = 1
2929
*/
3030
scaleY: number;
3131
/**
32-
* The horixontal offset of the line
32+
* The horizontal offset of the line
3333
* @default = 0
3434
*/
3535
offsetX: number;

dist/webglplot.d.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,15 @@ export default class WebGLPlot {
5353
*/
5454
gOffsetY: number;
5555
/**
56-
* collection of lines in the plot
56+
* collection of data lines in the plot
5757
*/
58-
private _lines;
59-
get lines(): WebglBaseLine[];
58+
private _linesData;
59+
/**
60+
* collection of auxiliary lines (grids, markers, etc) in the plot
61+
*/
62+
private _linesAux;
63+
get linesData(): WebglBaseLine[];
64+
get linesAux(): WebglBaseLine[];
6065
private progThinLine;
6166
/**
6267
* log debug output
@@ -104,6 +109,7 @@ export default class WebGLPlot {
104109
/**
105110
* updates and redraws the content of the plot
106111
*/
112+
private updateLines;
107113
update(): void;
108114
clear(): void;
109115
/**
@@ -116,16 +122,27 @@ export default class WebGLPlot {
116122
* wglp.addLine(line);
117123
* ```
118124
*/
119-
addLine(line: WebglLine | WebglStep | WebglPolar): void;
125+
private _addLine;
126+
addDataLine(line: WebglLine | WebglStep | WebglPolar): void;
127+
addLine: (line: WebglLine | WebglStep | WebglPolar) => void;
128+
addAuxLine(line: WebglLine | WebglStep | WebglPolar): void;
120129
private initThinLineProgram;
121130
/**
122-
* remove the last line
131+
* remove the last data line
123132
*/
124-
popLine(): void;
133+
popDataLine(): void;
125134
/**
126135
* remove all the lines
127136
*/
128137
removeAllLines(): void;
138+
/**
139+
* remove all data lines
140+
*/
141+
removeDataLines(): void;
142+
/**
143+
* remove all auxiliary lines
144+
*/
145+
removeAuxLines(): void;
129146
/**
130147
* Change the WbGL viewport
131148
* @param a

dist/webglplot.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/webglplot.esm.js

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ class WebGLPlot {
326326
* log debug output
327327
*/
328328
this.debug = false;
329+
this.addLine = this.addDataLine;
329330
if (options == undefined) {
330331
this.webgl = canvas.getContext("webgl", {
331332
antialias: true,
@@ -344,7 +345,8 @@ class WebGLPlot {
344345
}
345346
this.log("canvas type is: " + canvas.constructor.name);
346347
this.log(`[webgl-plot]:width=${canvas.width}, height=${canvas.height}`);
347-
this._lines = [];
348+
this._linesData = [];
349+
this._linesAux = [];
348350
//this.webgl = webgl;
349351
this.gScaleX = 1;
350352
this.gScaleY = 1;
@@ -358,15 +360,18 @@ class WebGLPlot {
358360
this.progThinLine = this.webgl.createProgram();
359361
this.initThinLineProgram();
360362
}
361-
get lines() {
362-
return this._lines;
363+
get linesData() {
364+
return this._linesData;
365+
}
366+
get linesAux() {
367+
return this._linesAux;
363368
}
364369
/**
365370
* updates and redraws the content of the plot
366371
*/
367-
update() {
372+
updateLines(lines) {
368373
const webgl = this.webgl;
369-
this.lines.forEach((line) => {
374+
lines.forEach((line) => {
370375
if (line.visible) {
371376
webgl.useProgram(this.progThinLine);
372377
const uscale = webgl.getUniformLocation(this.progThinLine, "uscale");
@@ -385,6 +390,10 @@ class WebGLPlot {
385390
}
386391
});
387392
}
393+
update() {
394+
this.updateLines(this.linesData);
395+
this.updateLines(this.linesAux);
396+
}
388397
clear() {
389398
// Clear the canvas //??????????????????
390399
//this.webgl.clearColor(0.1, 0.1, 0.1, 1.0);
@@ -400,7 +409,7 @@ class WebGLPlot {
400409
* wglp.addLine(line);
401410
* ```
402411
*/
403-
addLine(line) {
412+
_addLine(line) {
404413
//line.initProgram(this.webgl);
405414
line._vbuffer = this.webgl.createBuffer();
406415
this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);
@@ -409,7 +418,14 @@ class WebGLPlot {
409418
line._coord = this.webgl.getAttribLocation(this.progThinLine, "coordinates");
410419
this.webgl.vertexAttribPointer(line._coord, 2, this.webgl.FLOAT, false, 0, 0);
411420
this.webgl.enableVertexAttribArray(line._coord);
412-
this.lines.push(line);
421+
}
422+
addDataLine(line) {
423+
this._addLine(line);
424+
this.linesData.push(line);
425+
}
426+
addAuxLine(line) {
427+
this._addLine(line);
428+
this.linesAux.push(line);
413429
}
414430
initThinLineProgram() {
415431
const vertCode = `
@@ -441,16 +457,29 @@ class WebGLPlot {
441457
this.webgl.linkProgram(this.progThinLine);
442458
}
443459
/**
444-
* remove the last line
460+
* remove the last data line
445461
*/
446-
popLine() {
447-
this.lines.pop();
462+
popDataLine() {
463+
this.linesData.pop();
448464
}
449465
/**
450466
* remove all the lines
451467
*/
452468
removeAllLines() {
453-
this._lines = [];
469+
this._linesData = [];
470+
this._linesAux = [];
471+
}
472+
/**
473+
* remove all data lines
474+
*/
475+
removeDataLines() {
476+
this._linesData = [];
477+
}
478+
/**
479+
* remove all auxiliary lines
480+
*/
481+
removeAuxLines() {
482+
this._linesAux = [];
454483
}
455484
/**
456485
* Change the WbGL viewport

dist/webglplot.js

Lines changed: 40 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)