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

miglib

v2.0.8

Published

A TypeScript graphics and game development library built on p5.js: rendering, particle systems, vector/color math, sprite animation, tilesets, input, and audio.

Readme

MigLib

MigLib is a TypeScript graphics and game development library built on p5.js, providing utilities for rendering, particle systems, vector math, color manipulation, UI elements, and more.

Features

  • Screen-based architecture for organizing game/app content
  • Separate update and render phases each frame
  • Powerful graphics and particle system
  • Vector and color math utilities
  • Asset and sound management
  • Render-order mouse routing with pointer capture
  • Gamepad and input helpers
  • Easy p5.js integration

Quick Example

import { Starter, MigScreen, Graphics, Assets, Color } from 'miglib';

class MyScreen implements MigScreen {
    onShow(graphics: Graphics) {
        // Called when this screen is shown
    }
    onUpdate(graphics: Graphics) {
        // Optional. Game logic for this frame, run before onRender
    }
    onRender(graphics: Graphics) {
        graphics.renderText("Hello World", 100, 100, {
            size: 24,
            color: Color.col(255, 0, 0)
        });
    }
}

// Make sure the p5.js script is loaded globally before this runs.
// Starter creates and wires the p5 instance for you — you don't write
// p5's preload/setup/draw callbacks yourself.
const game = new Starter((assets: Assets) => {
    assets.loadImage("myImage", "myImage.png"); // resolved relative to the assets/ folder
    return new MyScreen();
});

game.start(); // optionally pass a container element: game.start(myDiv)

Example: Mouse Claims

Widgets are drawn by you, then claim their rect. The last claim under the cursor wins, so draw order is priority. A press captures that claim until the button comes up.

onRender(graphics: Graphics) {
    const rect = { x: 100, y: 100, w: 120, h: 40 };
    graphics.sketch.rect(rect.x, rect.y, rect.w, rect.h);

    graphics.mouse.claim("my-button", rect, {
        // There is no onClick: a click is a release inside, without a drag.
        onRelease: (info) => { if (info.inside && !info.wasDrag) this.doThing(); },
        onHover: () => graphics.renderText("tooltip", rect.x, rect.y - 6),
    });
}
  • Claim inside the push()/translate()/scale() block that positions the widget — the rect is in that space and the cursor is mapped through the live canvas transform for you.
  • graphics.mouse.pushClip(rect)/popClip() restrict hits to a region; nested clips intersect.
  • Per-frame state lives on the same object: graphics.mouse.justPressed, justReleased, isPressed, wheelDelta, wheelUp, wheelDown.
  • Query helpers: captured, hovered, isDragging, capturedBy(id), isHovered(id), isInside(id). Starter drives the router; screens never call begin()/end().

Example: Sprite Animation

const animator = new Animator();
animator.addAnimation(
    "walk",
    "character_spritesheet",
    [
        { x: 0, y: 0, w: 32, h: 32, duration: 100 },
        { x: 32, y: 0, w: 32, h: 32, duration: 100 },
        { x: 64, y: 0, w: 32, h: 32, duration: 100 },
        { x: 96, y: 0, w: 32, h: 32, duration: 100 }
    ]
);
animator.play("walk");

// Advance playback in your screen's onUpdate...
animator.update(graphics.deltaTime);

// ...and draw in onRender. render() never advances playback, so the frame you
// read with getCurrentFrameIndex() is the frame that gets drawn.
animator.render(100, 100, graphics, { w: 64, h: 64 });

Example: Playing Sounds

Sound.load("shoot", "sounds/shoot.mp3");
Sound.play("shoot");

More Documentation

See the full API and advanced usage in DOCS.md.