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

artmaker

v0.4.0

Published

art generator that uses the 2D canvas and shaders

Readme

artmaker

Maybe you want a wobbly Earthbound-style background for your HTML5 game jam game without much effort, or perhaps you just want a cool visual for your website. Either way, artmaker can help. Recently, I used it to add some style to this game prototype you can play in the browser here.

live example

The live example is also a good way to find cool patterns. By copying the seed (logged to the developer console) you can replicate the same pattern.

usage

You can use artmaker as a node module or directly in the browser.

with build tools

If you are familiar with npm, browserify and maybe TypeScript, the absolute best way to use this is to install it with npm install artmaker and import it like:

import ArtMaker from "./index";

with script tag

Of course, you can also simply include it as a script:

<script src="artmaker.min.js"></script>

For a complete example, see the file scriptexample.html.

general usage

You can add the canvas to the DOM and animate it with this:

const artMaker = new ArtMaker();
artMaker.animate();

This will add a canvas to the div with the id "art":

<div id="art"></div>

The new canvas will have an id of "artcanvas" so you can style it easily with CSS:

#artcanvas {
  width: 100%;
  border: 2px solid pink;
  /* this gives a nice crisp blocky effect when the canvas has a
  low resolution and is scaled up */
  image-rendering: pixelated;
}

You can pass in more arguments to the constructor to change the resolution and the ids of the elements. These are the defaults:

const artMaker = new ArtMaker(1920, 1080, "art", "artcanvas");

If you want to get the same pattern, you can seed the random generation by calling seed before animate. If you want to change the seed mid-animation, just call seed again. Calling it with no arguments will choose a random seed. They can be chained:

artMaker.seed("foo").animate();

If you have your own game loop, you don't have to call animate, and can just call draw in your game loop, passing in the current time in milliseconds:

// assuming your game is locked at 60
artMaker.draw(ticks * 60 * 1000);

You can override the color palette of the pattern with artMaker.setBackground([r, g, b]), artMaker.setForeground1([r, g, b]) and artMaker.setForeground2([r, g, b]). Note that many of the random effects do some form of color grading, so the colors you set might be completely different in the final image. The live demo is a good way to experiment with this; you can override colors with the controls in the top left.

Note that before 1.0, the generative algorithm might change, thus breaking seeds you might have saved from previous versions. If you save a shareable link from the live demo and try to visit it again after the algorithm has been updated, you'll be notified with an alert.

developing

npm run build will compile all the TypeScript into JavaScript and put it in dist. npm run bundle will bundle example.ts to create bundle.js which is used in index.html, which is the live example. To run this, you actually don't need a local server; you should be able to just open index.html with Chrome or Firefox directly. There are watch versions of these scripts: npm run buildwatch and npm run bundlewatch. To create the browser versions artmaker.js and artmaker.min.js, run npm run minify. These are the files included as the release.

final words

If you play with this library and find that you want some greater control over the output for practical purposes, maybe locked/unlocked framerate and timing options, let me know by creating an issue. If you happen to find a use for this weird project, let me know as well.

This project was started for a seminar on Generative Design taught by Gillian Smith. It also makes use two other libraries I wrote, merge-pass and postpre which were originally created to add post-processing effects to Charlie Robert's marching.js. I wouldn't have had the opportunity to create such a project without their guidance.