webgl-plot
Advanced tools
Comparing version 0.5.4 to 0.5.5
@@ -56,2 +56,12 @@ /** | ||
/** | ||
* Global log10 of x-axis | ||
* @default = false | ||
*/ | ||
gLog10X: boolean; | ||
/** | ||
* Global log10 of y-axis | ||
* @default = false | ||
*/ | ||
gLog10Y: boolean; | ||
/** | ||
* collection of data lines in the plot | ||
@@ -58,0 +68,0 @@ */ |
@@ -356,2 +356,4 @@ class ColorRGBA { | ||
this.gOffsetY = 0; | ||
this.gLog10X = false; | ||
this.gLog10Y = false; | ||
// Clear the color | ||
@@ -387,2 +389,4 @@ this.webgl.clear(this.webgl.COLOR_BUFFER_BIT); | ||
webgl.uniform2fv(uoffset, new Float32Array([line.offsetX + this.gOffsetX, line.offsetY + this.gOffsetY])); | ||
const isLog = webgl.getUniformLocation(this.progThinLine, "is_log"); | ||
webgl.uniform2iv(isLog, new Int32Array([this.gLog10X ? 1 : 0, this.gLog10Y ? 1 : 0])); | ||
const uColor = webgl.getUniformLocation(this.progThinLine, "uColor"); | ||
@@ -437,4 +441,9 @@ webgl.uniform4fv(uColor, [line.color.r, line.color.g, line.color.b, line.color.a]); | ||
uniform vec2 uoffset; | ||
uniform ivec2 is_log; | ||
void main(void) { | ||
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0); | ||
float x = (is_log[0]==1) ? log(coordinates.x) : coordinates.x; | ||
float y = (is_log[1]==1) ? log(coordinates.y) : coordinates.y; | ||
vec2 line = vec2(x, y); | ||
gl_Position = vec4(uscale*line + uoffset, 0.0, 1.0); | ||
}`; | ||
@@ -441,0 +450,0 @@ // Create a vertex shader object |
@@ -87,2 +87,4 @@ /** | ||
this.gOffsetY = 0; | ||
this.gLog10X = false; | ||
this.gLog10Y = false; | ||
// Clear the color | ||
@@ -118,2 +120,4 @@ this.webgl.clear(this.webgl.COLOR_BUFFER_BIT); | ||
webgl.uniform2fv(uoffset, new Float32Array([line.offsetX + this.gOffsetX, line.offsetY + this.gOffsetY])); | ||
const isLog = webgl.getUniformLocation(this.progThinLine, "is_log"); | ||
webgl.uniform2iv(isLog, new Int32Array([this.gLog10X ? 1 : 0, this.gLog10Y ? 1 : 0])); | ||
const uColor = webgl.getUniformLocation(this.progThinLine, "uColor"); | ||
@@ -168,4 +172,9 @@ webgl.uniform4fv(uColor, [line.color.r, line.color.g, line.color.b, line.color.a]); | ||
uniform vec2 uoffset; | ||
uniform ivec2 is_log; | ||
void main(void) { | ||
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0); | ||
float x = (is_log[0]==1) ? log(coordinates.x) : coordinates.x; | ||
float y = (is_log[1]==1) ? log(coordinates.y) : coordinates.y; | ||
vec2 line = vec2(x, y); | ||
gl_Position = vec4(uscale*line + uoffset, 0.0, 1.0); | ||
}`; | ||
@@ -172,0 +181,0 @@ // Create a vertex shader object |
@@ -362,2 +362,4 @@ (function (global, factory) { | ||
this.gOffsetY = 0; | ||
this.gLog10X = false; | ||
this.gLog10Y = false; | ||
// Clear the color | ||
@@ -393,2 +395,4 @@ this.webgl.clear(this.webgl.COLOR_BUFFER_BIT); | ||
webgl.uniform2fv(uoffset, new Float32Array([line.offsetX + this.gOffsetX, line.offsetY + this.gOffsetY])); | ||
const isLog = webgl.getUniformLocation(this.progThinLine, "is_log"); | ||
webgl.uniform2iv(isLog, new Int32Array([this.gLog10X ? 1 : 0, this.gLog10Y ? 1 : 0])); | ||
const uColor = webgl.getUniformLocation(this.progThinLine, "uColor"); | ||
@@ -443,4 +447,9 @@ webgl.uniform4fv(uColor, [line.color.r, line.color.g, line.color.b, line.color.a]); | ||
uniform vec2 uoffset; | ||
uniform ivec2 is_log; | ||
void main(void) { | ||
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0); | ||
float x = (is_log[0]==1) ? log(coordinates.x) : coordinates.x; | ||
float y = (is_log[1]==1) ? log(coordinates.y) : coordinates.y; | ||
vec2 line = vec2(x, y); | ||
gl_Position = vec4(uscale*line + uoffset, 0.0, 1.0); | ||
}`; | ||
@@ -447,0 +456,0 @@ // Create a vertex shader object |
{ | ||
"name": "webgl-plot", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "High-performance 2D plotting library based on native WebGL", | ||
@@ -5,0 +5,0 @@ "main": "./dist/webglplot.umd.js", |
@@ -151,2 +151,6 @@     | ||
## Benchmark | ||
[Line generation and Frame rate](https://danchitnis.github.io/webgl-plot/benchmark/bench1.html) | ||
## API Documentation | ||
@@ -153,0 +157,0 @@ |
@@ -66,2 +66,14 @@ /** | ||
/** | ||
* Global log10 of x-axis | ||
* @default = false | ||
*/ | ||
public gLog10X: boolean; | ||
/** | ||
* Global log10 of y-axis | ||
* @default = false | ||
*/ | ||
public gLog10Y: boolean; | ||
/** | ||
* collection of data lines in the plot | ||
@@ -159,2 +171,4 @@ */ | ||
this.gOffsetY = 0; | ||
this.gLog10X = false; | ||
this.gLog10Y = false; | ||
@@ -187,6 +201,6 @@ // Clear the color | ||
new Float32Array([ | ||
line.scaleX * this.gScaleX, | ||
line.scaleX * this.gScaleX * (this.gLog10X ? 1 / Math.log(10) : 1), | ||
0, | ||
0, | ||
line.scaleY * this.gScaleY * this.gXYratio, | ||
line.scaleY * this.gScaleY * this.gXYratio * (this.gLog10Y ? 1 / Math.log(10) : 1), | ||
]) | ||
@@ -201,2 +215,5 @@ ); | ||
const isLog = webgl.getUniformLocation(this.progThinLine, "is_log"); | ||
webgl.uniform2iv(isLog, new Int32Array([this.gLog10X ? 1 : 0, this.gLog10Y ? 1 : 0])); | ||
const uColor = webgl.getUniformLocation(this.progThinLine, "uColor"); | ||
@@ -263,4 +280,9 @@ webgl.uniform4fv(uColor, [line.color.r, line.color.g, line.color.b, line.color.a]); | ||
uniform vec2 uoffset; | ||
uniform ivec2 is_log; | ||
void main(void) { | ||
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0); | ||
float x = (is_log[0]==1) ? log(coordinates.x) : coordinates.x; | ||
float y = (is_log[1]==1) ? log(coordinates.y) : coordinates.y; | ||
vec2 line = vec2(x, y); | ||
gl_Position = vec4(uscale*line + uoffset, 0.0, 1.0); | ||
}`; | ||
@@ -267,0 +289,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
106620
2612
173