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

dkwdpil

v0.0.1

Published

Build interactive tutorials using p5js.

Downloads

9

Readme

DKWDP-InteractiveLib

A js library on top of p5js to build interactive tutorials.

Getting started

Clone the example project:

git clone [email protected]:Bluemi/dkwdp-tutorials.git
cd dkwdp-tutorials/minimal_template

Install the library:

npm install

Run the test server:

npx vite

Usage

Implementing scenes

Everything is implemented inside a scene. A scene is a class extending the Scene base class:

import {Context, Scene} from 'dkwdp-interactivelib';

export class MyScene extends Scene {
    update(context: Context) {
        // do stuff
    }
}

The update() method is called every frame. It is passed a Context object, which provides access to the canvas, audio, events and other utilities.

Initializing scenes

To use scenes, add them to the initScenes() call in index.html:

initScenes(
    sketchHolder,
    [
      ["startScene", new StartScene()],
      ["myScene", new MyScene()],
    ],
    ["sound.mp3"],
    ["image.png"]
);

Switching Scenes

To switch to another scene, set context.nextScene to the name of the scene you want to switch to:

export class MyScene extends Scene {
    update(context: Context) {
        // switch back after 5 seconds
        if (context.time > 5) {
            context.nextScene = "startScene";
        }
    }
}

Sprites

If you want to add an image to your scene you can do so by creating a Sprite object:

import {Context, Scene, Sprite} from 'dkwdp-interactivelib';

export class MyScene extends Scene {
    mySprite: Sprite = new Sprite("image.png", 0, 0, {size: 12.0, imageMode: "center"});

    update(context: Context) {
        context.background(235);
    }
}

Place the image.png file in the public folder.

Also you need to place the filename image.png in the initScenes() call in index.html:

Sprites are drawn automatically by the Scene class, because the Sprite class implements the InteractiveElement interface. Each member of the scene class, that implements the InteractiveElement interface, will be drawn and updated automatically.

Interactive Elements

You can implement your own interactive elements:

import {Context, INTERACTIVE_ELEMENT_MARKER, InteractiveElement} from "dkwdpil";

export class MyElement implements InteractiveElement {
    _interactiveElementMarker: "interactiveElement" = INTERACTIVE_ELEMENT_MARKER;

    update(context: Context) {
        for (const evt of context.events) {
            if (evt.kind === "mousedown") {
                // do stuff
            }
        }
    }

    draw(context: Context) {
        context.fill(255, 0, 0);
        context.rect(-5, -5, 10, 50);
    }
}

Draw methods are very similar to the p5js draw methods, but with a different coordinate system.

Coordinates

The coordinate system is a bit unusual:

  • The zero point is in the center of the screen.
  • The x-axis is horizontal and points to the right.
  • The y-axis is vertical and points up.
  • The top y-coordinate is 18 and the bottom y-coordinate is -18.
  • The left x-coordinate is -32 and the right x-coordinate is 32.
  • The width is always 64 and the height is always 36, resulting in a 16:9 aspect ratio.

Events

See the source code.