New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webgl-plot

Package Overview
Dependencies
Maintainers
1
Versions
42
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.5.7 to 0.5.8

2

dist/webglplot.d.ts

@@ -26,3 +26,3 @@ /**

*/
export default class WebGLPlot {
export declare class WebGLPlot {
/**

@@ -29,0 +29,0 @@ * @private

@@ -0,2 +1,307 @@

class ColorRGBA {
constructor(r, g, b, a) {
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
}
/**
* Baseline class
*/
class WebglBaseLine {
/**
* @internal
*/
constructor() {
this.scaleX = 1;
this.scaleY = 1;
this.offsetX = 0;
this.offsetY = 0;
this.loop = false;
this._vbuffer = 0;
this._coord = 0;
this.visible = true;
this.intensity = 1;
this.xy = new Float32Array([]);
this.numPoints = 0;
this.color = new ColorRGBA(0, 0, 0, 1);
this.webglNumPoints = 0;
}
}
/**
* The standard Line class
*/
class WebglLine extends WebglBaseLine {
/**
* Create a new line
* @param c - the color of the line
* @param numPoints - number of data pints
* @example
* ```typescript
* x= [0,1]
* y= [1,2]
* line = new WebglLine( new ColorRGBA(0.1,0.1,0.1,1), 2);
* ```
*/
constructor(c, numPoints) {
super();
this.webglNumPoints = numPoints;
this.numPoints = numPoints;
this.color = c;
this.xy = new Float32Array(2 * this.webglNumPoints);
}
/**
* Set the X value at a specific index
* @param index - the index of the data point
* @param x - the horizontal value of the data point
*/
setX(index, x) {
this.xy[index * 2] = x;
}
/**
* Set the Y value at a specific index
* @param index : the index of the data point
* @param y : the vertical value of the data point
*/
setY(index, y) {
this.xy[index * 2 + 1] = y;
}
/**
* Get an X value at a specific index
* @param index - the index of X
*/
getX(index) {
return this.xy[index * 2];
}
/**
* Get an Y value at a specific index
* @param index - the index of Y
*/
getY(index) {
return this.xy[index * 2 + 1];
}
/**
* Make an equally spaced array of X points
* @param start - the start of the series
* @param stepSize - step size between each data point
*
* @example
* ```typescript
* //x = [-1, -0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8]
* const numX = 10;
* line.lineSpaceX(-1, 2 / numX);
* ```
*/
lineSpaceX(start, stepSize) {
for (let i = 0; i < this.numPoints; i++) {
// set x to -num/2:1:+num/2
this.setX(i, start + stepSize * i);
}
}
/**
* Set a constant value for all Y values in the line
* @param c - constant value
*/
constY(c) {
for (let i = 0; i < this.numPoints; i++) {
// set x to -num/2:1:+num/2
this.setY(i, c);
}
}
/**
* Add a new Y values to the end of current array and shift it, so that the total number of the pair remains the same
* @param data - the Y array
*
* @example
* ```typescript
* yArray = new Float32Array([3, 4, 5]);
* line.shiftAdd(yArray);
* ```
*/
shiftAdd(data) {
const shiftSize = data.length;
for (let i = 0; i < this.numPoints - shiftSize; i++) {
this.setY(i, this.getY(i + shiftSize));
}
for (let i = 0; i < shiftSize; i++) {
this.setY(i + this.numPoints - shiftSize, data[i]);
}
}
}
/**
* The step based line plot
*/
class WebglStep extends WebglBaseLine {
/**
* Create a new step line
* @param c - the color of the line
* @param numPoints - number of data pints
* @example
* ```typescript
* x= [0,1]
* y= [1,2]
* line = new WebglStep( new ColorRGBA(0.1,0.1,0.1,1), 2);
* ```
*/
constructor(c, num) {
super();
this.webglNumPoints = num * 2;
this.numPoints = num;
this.color = c;
this.xy = new Float32Array(2 * this.webglNumPoints);
}
/**
* Set the Y value at a specific index
* @param index - the index of the data point
* @param y - the vertical value of the data point
*/
setY(index, y) {
this.xy[index * 4 + 1] = y;
this.xy[index * 4 + 3] = y;
}
getX(index) {
return this.xy[index * 4];
}
/**
* Get an X value at a specific index
* @param index - the index of X
*/
getY(index) {
return this.xy[index * 4 + 1];
}
/**
* Make an equally spaced array of X points
* @param start - the start of the series
* @param stepSize - step size between each data point
*
* @example
* ```typescript
* //x = [-1, -0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8]
* const numX = 10;
* line.lineSpaceX(-1, 2 / numX);
* ```
*/
lineSpaceX(start, stepsize) {
for (let i = 0; i < this.numPoints; i++) {
// set x to -num/2:1:+num/2
this.xy[i * 4] = start + i * stepsize;
this.xy[i * 4 + 2] = start + (i * stepsize + stepsize);
}
}
/**
* Set a constant value for all Y values in the line
* @param c - constant value
*/
constY(c) {
for (let i = 0; i < this.numPoints; i++) {
// set x to -num/2:1:+num/2
this.setY(i, c);
}
}
/**
* Add a new Y values to the end of current array and shift it, so that the total number of the pair remains the same
* @param data - the Y array
*
* @example
* ```typescript
* yArray = new Float32Array([3, 4, 5]);
* line.shiftAdd(yArray);
* ```
*/
shiftAdd(data) {
const shiftSize = data.length;
for (let i = 0; i < this.numPoints - shiftSize; i++) {
this.setY(i, this.getY(i + shiftSize));
}
for (let i = 0; i < shiftSize; i++) {
this.setY(i + this.numPoints - shiftSize, data[i]);
}
}
}
class WebglPolar extends WebglBaseLine {
constructor(c, numPoints) {
super();
this.webglNumPoints = numPoints;
this.numPoints = numPoints;
this.color = c;
this.intenisty = 1;
this.xy = new Float32Array(2 * this.webglNumPoints);
this._vbuffer = 0;
this._coord = 0;
this.visible = true;
this.offsetTheta = 0;
}
/**
* @param index: index of the line
* @param theta : angle in deg
* @param r : radius
*/
setRtheta(index, theta, r) {
//const rA = Math.abs(r);
//const thetaA = theta % 360;
const x = r * Math.cos((2 * Math.PI * (theta + this.offsetTheta)) / 360);
const y = r * Math.sin((2 * Math.PI * (theta + this.offsetTheta)) / 360);
//const index = Math.round( ((theta % 360)/360) * this.numPoints );
this.setX(index, x);
this.setY(index, y);
}
getTheta(index) {
//return Math.tan
return 0;
}
getR(index) {
//return Math.tan
return Math.sqrt(Math.pow(this.getX(index), 2) + Math.pow(this.getY(index), 2));
}
setX(index, x) {
this.xy[index * 2] = x;
}
setY(index, y) {
this.xy[index * 2 + 1] = y;
}
getX(index) {
return this.xy[index * 2];
}
getY(index) {
return this.xy[index * 2 + 1];
}
}
/**
* The Square class
*/
class WebglSquare extends WebglBaseLine {
/**
* Create a new line
* @param c - the color of the line
* @example
* ```typescript
* line = new WebglSquare( new ColorRGBA(0.1,0.1,0.1,0.5) );
* ```
*/
constructor(c) {
super();
this.webglNumPoints = 4;
this.numPoints = 4;
this.color = c;
this.xy = new Float32Array(2 * this.webglNumPoints);
}
/**
* draw a square
* @param x1 start x
* @param y1 start y
* @param x2 end x
* @param y2 end y
*/
setSquare(x1, y1, x2, y2) {
this.xy = new Float32Array([x1, y1, x1, y2, x2, y1, x2, y2]);
}
}
/**
* Author Danial Chitnis 2019-20

@@ -8,12 +313,6 @@ *

*/
import { ColorRGBA } from "./ColorRGBA";
import { WebglLine } from "./WbglLine";
import { WebglStep } from "./WbglStep";
import { WebglPolar } from "./WbglPolar";
import { WebglSquare } from "./WbglSquare";
export { WebglLine, ColorRGBA, WebglStep, WebglPolar, WebglSquare };
/**
* The main class for the webgl-plot library
*/
export default class WebGLPlot {
class WebGLPlot {
/**

@@ -277,2 +576,3 @@ * Create a webgl-plot instance

}
//# sourceMappingURL=webglplot.js.map
export { ColorRGBA, WebGLPlot, WebglLine, WebglPolar, WebglSquare, WebglStep };

@@ -583,2 +583,3 @@ (function (global, factory) {

exports.ColorRGBA = ColorRGBA;
exports.WebGLPlot = WebGLPlot;
exports.WebglLine = WebglLine;

@@ -588,3 +589,2 @@ exports.WebglPolar = WebglPolar;

exports.WebglStep = WebglStep;
exports.default = WebGLPlot;

@@ -591,0 +591,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

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

@@ -5,0 +5,0 @@ "main": "./dist/webglplot.umd.js",

@@ -30,3 +30,3 @@ /**

*/
export default class WebGLPlot {
export class WebGLPlot {
/**

@@ -33,0 +33,0 @@ * @private

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