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

u5js

v0.6.1

Published

u5.js is a minimalist and lightweight canvas animation library

Downloads

22

Readme

npm version bundle size

u5.js

u5.js is a minimalist and lightweight canvas animation library. Its API is essentially a stripped down version of the popular p5.js library which focuses on 2D canvas animation.

Why does this library exists?

I have been using and loving p5.js since 2014, it is all over my website ucodia.space, including the home page. Though the p5.js library was never built to be tree-shakeable and is now over 800KB, which is very large if all you need is to animate simple primitives.

There is an exisiting issue in the p5.js GitHub repository, though it seems the way the library is built makes it impossible to enable tree-shaking while remaining backward compatible.

As such I have decided to give a try at building a library with the same API which focuses only on 2D canvas animation.

Feature support

Environment

  • frameCount
  • deltaTime
  • frameRate()
  • windowWidth
  • windowHeight
  • windowResized()
  • width
  • height

Color - Setting

  • background()
  • clear()
  • fill()
  • noFill()
  • noStroke()
  • stroke()

Shape - 2D primitives

  • circle()
  • ellipse()
  • line()
  • rect()
  • square()
  • triangle()

Shape - Attributes

  • strokeWeight()

Constants

  • HALF_PI
  • PI
  • QUARTER_PI
  • TAU
  • TWO_PI

Structure

  • setup()
  • draw()
  • remove()
  • noLoop()
  • loop()
  • u5()

Rendering

  • createCanvas()
  • resizeCanvas()

Transform

  • rotate()
  • translate()
  • scale()

Events - Mouse

  • mouseX
  • mouseY
  • pmouseX
  • pmouseY
  • mouseIsPressed
  • mouseMoved()
  • mousePressed()
  • mouseReleased()
  • doubleClicked()

Math

  • map()
  • constrain()

Planned new features

  • Auto-sizing canvas
  • Out of the box support for SVG export (no animation)

Example: setup and draw

Here is an equivalent to p5.js setup and draw example.

const example = (sketch) => {
  let y = 100;

  sketch.setup = function () {
    sketch.createCanvas(720, 400);
    sketch.stroke("white");
    sketch.frameRate(30);
  };

  sketch.draw = function () {
    sketch.background("black");
    y = y - 1;
    if (y < 0) {
    y = sketch.height;
    }
    sketch.line(0, y, sketch.width, y);
  };
};

new u5(example, document.getElementById("container"));