Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webgl-plot

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webgl-plot - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

5

dist/WebglBaseLine.d.ts

@@ -6,2 +6,5 @@ import { ColorRGBA } from "./ColorRGBA";

export declare class WebglBaseLine {
private static readonly vertCode;
private static readonly fragCode;
private static program;
intensity: number;

@@ -67,2 +70,4 @@ visible: boolean;

_coord: number;
initProgram(webgl: WebGLRenderingContext): void;
private createProgram;
/**

@@ -69,0 +74,0 @@ * @internal

@@ -20,3 +20,36 @@ /**

}
initProgram(webgl) {
if (!WebglBaseLine.program) {
this.createProgram(webgl);
}
this._prog = WebglBaseLine.program;
}
createProgram(webgl) {
const vertShader = webgl.createShader(webgl.VERTEX_SHADER);
webgl.shaderSource(vertShader, WebglBaseLine.vertCode);
webgl.compileShader(vertShader);
const fragShader = webgl.createShader(webgl.FRAGMENT_SHADER);
webgl.shaderSource(fragShader, WebglBaseLine.fragCode);
webgl.compileShader(fragShader);
WebglBaseLine.program = webgl.createProgram();
webgl.attachShader(WebglBaseLine.program, vertShader);
webgl.attachShader(WebglBaseLine.program, fragShader);
webgl.linkProgram(WebglBaseLine.program);
}
}
WebglBaseLine.vertCode = `
attribute vec2 coordinates;
uniform mat2 uscale;
uniform vec2 uoffset;
void main(void) {
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0);
}`;
WebglBaseLine.fragCode = `
precision mediump float;
uniform highp vec4 uColor;
void main(void) {
gl_FragColor = uColor;
}`;
//# sourceMappingURL=WebglBaseLine.js.map

62

dist/webglplot.esm.js

@@ -29,4 +29,37 @@ class ColorRGBA {

}
initProgram(webgl) {
if (!WebglBaseLine.program) {
this.createProgram(webgl);
}
this._prog = WebglBaseLine.program;
}
createProgram(webgl) {
const vertShader = webgl.createShader(webgl.VERTEX_SHADER);
webgl.shaderSource(vertShader, WebglBaseLine.vertCode);
webgl.compileShader(vertShader);
const fragShader = webgl.createShader(webgl.FRAGMENT_SHADER);
webgl.shaderSource(fragShader, WebglBaseLine.fragCode);
webgl.compileShader(fragShader);
WebglBaseLine.program = webgl.createProgram();
webgl.attachShader(WebglBaseLine.program, vertShader);
webgl.attachShader(WebglBaseLine.program, fragShader);
webgl.linkProgram(WebglBaseLine.program);
}
}
WebglBaseLine.vertCode = `
attribute vec2 coordinates;
uniform mat2 uscale;
uniform vec2 uoffset;
void main(void) {
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0);
}`;
WebglBaseLine.fragCode = `
precision mediump float;
uniform highp vec4 uColor;
void main(void) {
gl_FragColor = uColor;
}`;
/**

@@ -389,33 +422,6 @@ * The standard Line class

addLine(line) {
line.initProgram(this.webgl);
line._vbuffer = this.webgl.createBuffer();
this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);
this.webgl.bufferData(this.webgl.ARRAY_BUFFER, line.xy, this.webgl.STREAM_DRAW);
const vertCode = `
attribute vec2 coordinates;
uniform mat2 uscale;
uniform vec2 uoffset;
void main(void) {
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0);
}`;
// Create a vertex shader object
const vertShader = this.webgl.createShader(this.webgl.VERTEX_SHADER);
// Attach vertex shader source code
this.webgl.shaderSource(vertShader, vertCode);
// Compile the vertex shader
this.webgl.compileShader(vertShader);
// Fragment shader source code
const fragCode = `
precision mediump float;
uniform highp vec4 uColor;
void main(void) {
gl_FragColor = uColor;
}`;
const fragShader = this.webgl.createShader(this.webgl.FRAGMENT_SHADER);
this.webgl.shaderSource(fragShader, fragCode);
this.webgl.compileShader(fragShader);
line._prog = this.webgl.createProgram();
this.webgl.attachShader(line._prog, vertShader);
this.webgl.attachShader(line._prog, fragShader);
this.webgl.linkProgram(line._prog);
this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);

@@ -422,0 +428,0 @@ line._coord = this.webgl.getAttribLocation(line._prog, "coordinates");

@@ -121,33 +121,6 @@ /**

addLine(line) {
line.initProgram(this.webgl);
line._vbuffer = this.webgl.createBuffer();
this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);
this.webgl.bufferData(this.webgl.ARRAY_BUFFER, line.xy, this.webgl.STREAM_DRAW);
const vertCode = `
attribute vec2 coordinates;
uniform mat2 uscale;
uniform vec2 uoffset;
void main(void) {
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0);
}`;
// Create a vertex shader object
const vertShader = this.webgl.createShader(this.webgl.VERTEX_SHADER);
// Attach vertex shader source code
this.webgl.shaderSource(vertShader, vertCode);
// Compile the vertex shader
this.webgl.compileShader(vertShader);
// Fragment shader source code
const fragCode = `
precision mediump float;
uniform highp vec4 uColor;
void main(void) {
gl_FragColor = uColor;
}`;
const fragShader = this.webgl.createShader(this.webgl.FRAGMENT_SHADER);
this.webgl.shaderSource(fragShader, fragCode);
this.webgl.compileShader(fragShader);
line._prog = this.webgl.createProgram();
this.webgl.attachShader(line._prog, vertShader);
this.webgl.attachShader(line._prog, fragShader);
this.webgl.linkProgram(line._prog);
this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);

@@ -154,0 +127,0 @@ line._coord = this.webgl.getAttribLocation(line._prog, "coordinates");

@@ -35,4 +35,37 @@ (function (global, factory) {

}
initProgram(webgl) {
if (!WebglBaseLine.program) {
this.createProgram(webgl);
}
this._prog = WebglBaseLine.program;
}
createProgram(webgl) {
const vertShader = webgl.createShader(webgl.VERTEX_SHADER);
webgl.shaderSource(vertShader, WebglBaseLine.vertCode);
webgl.compileShader(vertShader);
const fragShader = webgl.createShader(webgl.FRAGMENT_SHADER);
webgl.shaderSource(fragShader, WebglBaseLine.fragCode);
webgl.compileShader(fragShader);
WebglBaseLine.program = webgl.createProgram();
webgl.attachShader(WebglBaseLine.program, vertShader);
webgl.attachShader(WebglBaseLine.program, fragShader);
webgl.linkProgram(WebglBaseLine.program);
}
}
WebglBaseLine.vertCode = `
attribute vec2 coordinates;
uniform mat2 uscale;
uniform vec2 uoffset;
void main(void) {
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0);
}`;
WebglBaseLine.fragCode = `
precision mediump float;
uniform highp vec4 uColor;
void main(void) {
gl_FragColor = uColor;
}`;
/**

@@ -395,33 +428,6 @@ * The standard Line class

addLine(line) {
line.initProgram(this.webgl);
line._vbuffer = this.webgl.createBuffer();
this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);
this.webgl.bufferData(this.webgl.ARRAY_BUFFER, line.xy, this.webgl.STREAM_DRAW);
const vertCode = `
attribute vec2 coordinates;
uniform mat2 uscale;
uniform vec2 uoffset;
void main(void) {
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0);
}`;
// Create a vertex shader object
const vertShader = this.webgl.createShader(this.webgl.VERTEX_SHADER);
// Attach vertex shader source code
this.webgl.shaderSource(vertShader, vertCode);
// Compile the vertex shader
this.webgl.compileShader(vertShader);
// Fragment shader source code
const fragCode = `
precision mediump float;
uniform highp vec4 uColor;
void main(void) {
gl_FragColor = uColor;
}`;
const fragShader = this.webgl.createShader(this.webgl.FRAGMENT_SHADER);
this.webgl.shaderSource(fragShader, fragCode);
this.webgl.compileShader(fragShader);
line._prog = this.webgl.createProgram();
this.webgl.attachShader(line._prog, vertShader);
this.webgl.attachShader(line._prog, fragShader);
this.webgl.linkProgram(line._prog);
this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);

@@ -428,0 +434,0 @@ line._coord = this.webgl.getAttribLocation(line._prog, "coordinates");

{
"name": "webgl-plot",
"version": "0.4.1",
"version": "0.5.0",
"description": "High-performance 2D plotting library based on native WebGL",

@@ -10,9 +10,9 @@ "main": "./dist/webglplot.umd.js",

"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
"rollup": "^2.23.1",
"typedoc": "^0.17.8",
"typedoc-plugin-markdown": "^2.4.0",
"typescript": "^3.9.7"
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"eslint": "^7.7.0",
"rollup": "^2.26.8",
"typedoc": "^0.19.0",
"typedoc-plugin-markdown": "^2.4.2",
"typescript": "^4.0.2"
},

@@ -34,2 +34,2 @@ "scripts": {

"homepage": "https://github.com/danchitnis/webgl-plot"
}
}
![npm](https://github.com/danchitnis/webgl-plot/workflows/npm/badge.svg) ![yarn](https://github.com/danchitnis/webgl-plot/workflows/yarn/badge.svg) ![Code scanning](https://github.com/danchitnis/webgl-plot/workflows/Code%20scanning/badge.svg) ![Build](https://github.com/danchitnis/webgl-plot/workflows/Build/badge.svg)
## [Live demo 🚀](https://danchitnis.github.io/webgl-plot-examples/)
## [Live demo 🚀](https://danchitnis.github.io/webgl-plot-examples/vanilla/)

@@ -5,0 +5,0 @@ # webgl-plot

@@ -7,2 +7,21 @@ import { ColorRGBA } from "./ColorRGBA";

export class WebglBaseLine {
private static readonly vertCode = `
attribute vec2 coordinates;
uniform mat2 uscale;
uniform vec2 uoffset;
void main(void) {
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0);
}`;
private static readonly fragCode = `
precision mediump float;
uniform highp vec4 uColor;
void main(void) {
gl_FragColor = uColor;
}`;
private static program: WebGLProgram;
public intensity: number;

@@ -81,2 +100,24 @@ public visible: boolean;

public initProgram(webgl: WebGLRenderingContext) {
if(!WebglBaseLine.program) {
this.createProgram(webgl);
}
this._prog = WebglBaseLine.program;
}
private createProgram(webgl: WebGLRenderingContext) {
const vertShader = webgl.createShader(webgl.VERTEX_SHADER);
webgl.shaderSource(vertShader as WebGLShader, WebglBaseLine.vertCode);
webgl.compileShader(vertShader as WebGLShader);
const fragShader = webgl.createShader(webgl.FRAGMENT_SHADER);
webgl.shaderSource(fragShader as WebGLShader, WebglBaseLine.fragCode);
webgl.compileShader(fragShader as WebGLShader);
WebglBaseLine.program = webgl.createProgram() as WebGLProgram;
webgl.attachShader(WebglBaseLine.program, vertShader as WebGLShader);
webgl.attachShader(WebglBaseLine.program, fragShader as WebGLShader);
webgl.linkProgram(WebglBaseLine.program);
}
/**

@@ -83,0 +124,0 @@ * @internal

@@ -190,2 +190,3 @@ /**

public addLine(line: WebglBaseLine): void {
line.initProgram(this.webgl);
line._vbuffer = this.webgl.createBuffer() as WebGLBuffer;

@@ -195,36 +196,2 @@ this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);

const vertCode = `
attribute vec2 coordinates;
uniform mat2 uscale;
uniform vec2 uoffset;
void main(void) {
gl_Position = vec4(uscale*coordinates + uoffset, 0.0, 1.0);
}`;
// Create a vertex shader object
const vertShader = this.webgl.createShader(this.webgl.VERTEX_SHADER);
// Attach vertex shader source code
this.webgl.shaderSource(vertShader as WebGLShader, vertCode);
// Compile the vertex shader
this.webgl.compileShader(vertShader as WebGLShader);
// Fragment shader source code
const fragCode = `
precision mediump float;
uniform highp vec4 uColor;
void main(void) {
gl_FragColor = uColor;
}`;
const fragShader = this.webgl.createShader(this.webgl.FRAGMENT_SHADER);
this.webgl.shaderSource(fragShader as WebGLShader, fragCode);
this.webgl.compileShader(fragShader as WebGLShader);
line._prog = this.webgl.createProgram() as WebGLProgram;
this.webgl.attachShader(line._prog, vertShader as WebGLShader);
this.webgl.attachShader(line._prog, fragShader as WebGLShader);
this.webgl.linkProgram(line._prog);
this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);

@@ -231,0 +198,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc