npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

glovebox

v0.2.5

Published

WebGl 2D optimized library, targets large fancy data presentation scenarios.

Downloads

3

Readme

NPM version Dependencies

Introduction

This is a library targets 2D hardware-acclerated graphic rendering. This is useful in data presentation scenario

#Installation

npm i glovebox -S

#Example Custom Component

class Triangle extends Drawable {
    constructor() {
        super(
            `
                attribute vec2 a_position;
                attribute vec3 a_color;
                varying vec3 v_color;

                void main() {
                    gl_Position = projection(a_position);
                    v_color = a_color;
                }
            `,
            `
                varying vec3 v_color;
                uniform vec3 u_color;
                void main() {
                    gl_FragColor = vec4(v_color, 1.0);
                    //gl_FragColor = vec4(u_color, 1.0);
                }
            `
        );
        this._endIndex = 3;
        const colors = new Attribute(new Float32Array(9), Attribute.FLOAT, 3);
        colors.set(0, 1, 0, 0);
        colors.set(1, 0, 1, 0);
        colors.set(2, 0, 0, 1);

        const vertices = new Attribute(new Float32Array(6), Attribute.FLOAT, 2);
        vertices.set(0, 0, 0);
        vertices.set(1, 0, 100);
        vertices.set(2, 100, 100);

        this.attachAttribute('a_position', vertices);
        this.attachAttribute('a_color', colors);
    }
}

Components

Box

  • constructor(width: number, height: number)
  • width: number
  • height: number
  • color: number
  • opacity: number

BoxImage

  • constructor(texture: Texture, width: number, height: number)
  • width: number
  • height: number

LineMesh

  • constructor(vertices: Vector2[], width: number)
  • color: number
  • opacity: number
  • width: number

Text

  • constructor(font: Font, text: string, height: number)
  • color: number
  • opacity: number
  • readonly width: number
  • height: number
  • font: Font
  • text: string

Sprite

  • constructor(texture: Texture, tileWidth: number, tileHeight: number, width: number, height: number)
  • width: number
  • height: number
  • tileWidth: number
  • tileHeight: number
  • xIndex: number
  • yIndex: number

Polygon

  • constructor(points: Vector2[]);
  • color: number;
  • opacity: number;
  • points: Vector2[];

Core

All components inherited from Drawable

Drawable

  • constructor(vertexShaderString: string, fragmentShaderString: string);
  • readonly drawMethod: Constants.DrawMethod;
  • readonly elementType: Constants.ElementType;
  • readonly id: number, unique id, auto assigned.
  • rotation: boolean, set component rotation, in radians
  • scale: Vector2, set scale
  • position: Vector2, et position
  • zIndex: number
  • protected _drawType: Constants.DrawType, set up draw type
  • startIndex: number, draw vertices start at
  • endIndx: number, draw vertices end at
  • name: string, name of the component

Stage

Stage holds all components.

  • constructor(width?: number, height?: number, canvas?: HTMLCanvasElement), use default canvas or your own
  • add(child: Drawable), add child to stage
  • remove(child: Drawable), remove child from stage
  • clear(), clear stage
  • camera: Vector2,
  • scale: Vector2,
  • clickTest(x: number, y: number): number, test if there is a component at given coordinates, 0 is returned if not, id is returned if true
  • render(), render stage

Color

constructor(hex: number, opacity?: number)

  • value: numebr, hex value of RGB color
  • opacity, opacity
  • readonly r: number
  • readonly g: number
  • readonly b: number

all set operations will trigger update/remount of attributes/uniforms

Attribute

  • constructor(buffer: TypedArray, type: Constants.AttributeType, dataSize: number)
  • set(index: number, ...data: number[]), set data at given index
  • get(index: number): number[], get data at given index
  • indexBuffer: Uint8Array | Uint16Array, index array for current vertex.
  • replaceWith(buffer: TypedArray)

Uniform

  • constructor(type: Constants.UniformType, size: number)
  • set(...data: number[]), set uniform value
  • get(): number[], get uniform value

ArrayUniform

  • constructor(type: Constants.UniformType, size: number)
  • set(index: number, ...data: number[]), set data at given index

MatrixUniform

  • constructor(size: number)
  • set(col: number, row: number, value: number), set data
  • replace(buffer: Float32Array), replace data with array
  • readonly size: number, get size
  • get(col: number, row: number): number, get data

TextureUniform

all attributes come with default value (WebGl respected).

  • constructor(image: Texture)
  • image: Texture
  • packAlignment: Constants.TextureAlignment
  • unpackAlignment: Constants.TextureAlignment
  • unpackFlipY: boolean
  • unpackPremultiplyAlpha: boolean
  • magFilter: Constants.TextureMagFilter
  • minFilter: Constants.TextureMinFilter
  • wrapS: Constants.TextureWrap
  • wrapT: Constants.TextureWrap
  • format: Constants.TextureFormat
  • level: number
  • texelFormat: Constants.TextureTexelFormat

Texture

  • static loadTexture(src: string): Promise
  • static fromImage(image: Constants.WebImage): Texture

Font

  • static loadFont(src: string, fontSize: number): Promise

Constants

AttributeUsage

  • STATIC_DRAW
  • DYNAMIC_DRAW
  • STREAM_DRAW

AttributeType

  • BYTE
  • UNSIGNED_BYTE
  • SHORT
  • UNSIGNED_SHORT
  • FLOAT

DrawMethod

  • ARRAYS
  • ELEMENTS

ElementType

  • UNSIGNED_BYTE
  • UNSIGNED_SHORT

DrawType

  • POINTS
  • LINES
  • LINE_STRIP
  • LINE_LOOP
  • TRIANGLES
  • TRIANGLE_STRIP
  • TRIANGLE_FAN

UniformType

  • INT
  • FLOAT

TextureMagFilter

  • LINEAR
  • NEAREST

TextureMinFilter

  • LINEAR
  • NEAREST_MIPMAP_NEAREST
  • LINEAR_MIPMAP_NEAREST
  • NEAREST_MIPMAP_LINEAR
  • LINEAR_MIPMAP_LINEAR

TextureWrap

  • REPEAT
  • CLAMP_TO_EDGE
  • MIRRORED_REPEAT

TextureFormat

  • ALPHA
  • RGB
  • RGBA
  • LUMINANCE
  • LUMINANCE_ALPHA

TextureTexelFormat

  • UNSIGNED_BYTE
  • UNSIGNED_SHORT_5_6_5
  • UNSIGNED_SHORT_4_4_4_4
  • UNSIGNED_SHORT_5_5_5_1

type WebImage

  • ImageData
  • HTMLImageElement
  • HTMLCanvasElement
  • HTMLVideoElement

type TextureAlignment

  • 1
  • 2
  • 4
  • 8

type TypedArray

  • Int8Array
  • Uint8Array
  • Int16Array
  • Uint16Array
  • Uint32Array
  • Float32Array

Utils

ImageUtil

  • static loadAsScaled(src: string): Promise
  • static loadAsPadded(src: string, padColor: Color): Promise