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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vect-js

v1.0.21

Published

Mathematical animation engine for the web.

Readme

vect-js

Edit empty-glade-v6r37

Easily create interactive mathematical simulation or animations for the web. ⚠️ WARNING! ⚠️ This library is still in early development and is not only for experimental and testing usage. Documentation is still of poor quality, because API is still forming. First stable and better documented release will be v1.1.0

Examples

Installing

npm i vect-js

Usage

Minimal example rendering two vectors and their sum.

import Vect, { Context, Shape, Vector } from "vect-js";

// tell vect where to render ui
const vectContainer = document.body;

const vect = Vect(Context.CANVAS_2D, {
  // renders canvas inside container
  container: vectContainer,
  // sets canvas backgkround color
  backgroundColor: "#000000",
  // draws coordinate numbers
  displayNumbers: false,
  // draws emphasized basis coordinates (x=0, y=0)
  displayBasis: false,
  // draws coordinate grid
  displayGrid: false,
  // space between grid coordinate lines
  coordinatesDelta: 100,
  // render canvas in high pixel density
  highPixelDensity: true,
  // enable drag around with mouse
  enableMouseMove: true
});

// starting position of vector arrow (default 0,0)
const p0 = new Shape.Arrow([0,0]);

const v1 = new Shape.Arrow(p0, new Vector([100,50]), '#FFFFFF');
const v2 = new Shape.Arrow(p0, new Vector([50,100]), '#FFFFFF');
const sum1 = new Shape.Arrow(p0, v1.vector.add(v2.vector), '#db002f');

// add shapes to render
vect.addShapes([v1,v2,sum1]);

Updating shapes

import { Shape, Vector } from 'vect-js';

// initialize with position and radius
let circle = new Shape.Circle(new Vector([0, 0]), 10);

// state update callback called by renderer (60 times per sec)
circle.onUpdate = function () {
  // update position with velocity vector
  // NOTE: math object (Vector, Matrix) are immutable
  this.position = this.position.add(new Vector([10,10]));
}

Mouse events on shapes

const c = new Shape.Circle(new Vector([0, 0]), 10);

// called when shape intersects with mouse position
c.onHover = function (m: MouseState) {
  // update state variables
  this.position = new Vector([0,0]);
  // you can also return ShapeStyles object that updates shape
  return {
    fillColor: '#FFFFFF',
    strokeColor: '#FFFFFF',
    size: 2
  }
};

// called when pressed mouse intersects with shape
c.onDrag = function (m: MouseState) {
  // update state variables or/and return styles
};

// called when mouse clicks on shape
c.onClick = function (m: MouseState) {
  // update state variables or/and return styles
};

Updating coordinate system

vect.onUpdate = function () {

  // translate coordinates
  this.translate(new Vector([10, 100]));

  // transform coordinates (zoom, skew)
  this.transform(new Matrix([[0.9999, 0], [0, 0.9999]]));
}

Development

  1. clone repo git clone https://github.com/bartolomej/vect && cd vect
  2. install dependencies npm i
  3. run tests npm test
  4. run example apps npm position

Building

There are 4 build configurations:

  • empty - main library
  • test - builds live library tests in the browser
  • docs - builds library documentation with examples
  • examples - builds library usage examples

Scripts

  1. Run live hot-reloading npm run start:<build-config>
  2. Builds for production npm run build:<build-config>