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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pattaya/depict

v0.6.1

Published

make it easy to design dynamic graph in canvas environment

Downloads

382

Readme

Depict

Depict is a JavaScript library for building canvas based user interface.

  • Declarative: Depict makes it painless to create complex animation and events driven graph without mind burden.
  • Maintainable: Organize simple and clear nodes to Create complex shapes, there are no specific positioning or layout engines included, the only thing you need to care about is its offset, nothing specific to learn. You don't need to consider the relationship among different components, nodes or shapes, and try to manage complex application state communication.
  • Performance: Performance auto tuning battery is included. However, if you try to build something really fast, many optional performance tools are available. Demonstrate your app fastly and improve it later if it's necessary. But it's fast enough in most of the cases
  • Multi-pattern: You can build your graph driven by function varibles, or simple state, or even react state, vue state, the graph will be driven by what you expect, no annoying communication between shapes, elements...

Installation

npm install @pattaya/depict --save

Examples

examples

You can create graph application with any other framework you like,
there are some demo applications which include React, Vue, Svelte, or vanilla javascript based graph,
listed as follows:

for every application in the examples directory, you can run the application with the following steps.

cd exmaples/xxx

# install packages
npm install

# run the application
npm run dev

Quick Guide

First, you should create a depict instance to hold the graph canvas DOM.

import { Depict } from "@pattaya/depict";

const worker = new Worker(new URL('xxx/worker.ts', import.meta.url), {
  type: "module"
})

const graphContainer = new Depict({
  root: canvasHTMLDivElement,
  maxLayers: 3,
  worker,
});

graphContainer.start();

then you should create a web worker file to actually run the graph.

import { Graph, MessageType } from "@pattaya/depict/graph";

const graph = new Graph();

onmessage = (ev) => {
  graph.handleMessageEvent(ev);
};

Now, you can build your image with an array of nodes.
You can add events, animation or even state system if you want to build something big.

const node = {
  x: 150,
  y: 145,
  shapes: [
    {
      path: "M 20 20 l 0 100",
      opts: {
        stroke: "#666",
        fill: "#333",
      }
    }
  ],
};
graph.updateQueue(2, [node]);

features

works in the todo list:

  • [x] support single thread version.
  • [x] provide api to get text rect information.
  • [x] support text align.
  • [ ] support change element render priority.
  • [ ] support bounding box ?
  • [ ] provide a new animated renderer ?
  • [ ] more examples: render image, animation

License

MIT