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

earthbound-battle-backgrounds-vite

v4.0.0

Published

An API to render Earthbound's battle backgrounds in your browser

Readme

earthbound-battle-backgrounds-vite

This project acts as a library to render Earthbound's battle backgrounds. You can render the results in a browser or even on the server.

This fork is an updated version of kdex's original library. I first migrated the codebase from Webpack to Rollup for performance and smaller bundle sizes, and later to Vite for future-proofing.

What is this?

Earthbound, also known as Mother 2 in Japan, is a SNES game released in 1994. This project displays Earthbound's battle backgrounds. In order to render the frames, currently a Canvas 2D context is used.

import { BackgroundLayer, Engine } from "earthbound-battle-backgrounds-vite";

/* Create animation engine  */
const engine = new Engine([new BackgroundLayer(153), new BackgroundLayer(298)], {
    canvas: document.querySelector("#target-canvas")
});
engine.animate();

API

There are two exports in the package, namely BackgroundLayer and Engine.

BackgroundLayer

constructor(entry)

Description

Creates a new BackgroundLayer displaying entry.

Signature
  • entry: number

The index of the layer to render. It is bounded by BackgroundLayer.MINIMUM_LAYER and BackgroundLayer.MAXIMUM_LAYER.

Engine

constructor(layers, options)

Description

Constructs a new Engine, which can be used to render BackgroundLayers.

Signature
  • layers: Array<BackgroundLayer> (default: [])

The array of BackgroundLayer instances to render.

  • options: object

An object containing rendering options.

  • options.fps: number (default: 30)

The framerate to render with.

  • options.aspectRatio: number (default: 0)

The aspect ratio to render with.

  • options.frameSkip: number (default: 1)

The engine is time-dependent and uses an internal clock that will be incremented after each frame. This number decides by which constant the clock is incremented.

  • options.alpha: Array<number> (default: Engine.computeAlphas(layers.map(layer => layer.entry)))

An array that specifies the opacity for each BackgroundLayer in layers. The default is to give each layer the same opacity so that all alphas sum up to 1. Layer 0 is ignored, as it does not display anything.

  • options.canvas: CanvasElement (default: document.querySelector("canvas"))

The canvas element to render to.

static computeAlphas(entries)

Description

Computes an array of alpha values so that every valid layer gets the same opacity.

Signature
  • entries: Array<number>

An array where every number must be a number must be at least BackgroundLayer.MINIMUM_LAYER, and at most BackgroundLayer.MAXIMUM_LAYER.

rewind()

Description

Resets the internal engine timer to 0. This will cause all BackgroundLayers to be rendered in their initial state.

Signature

Nullary.

animate()

Description

Runs the engine. This will cause frames to be drawn on the instance's canvas.

Signature

Nullary.

Project maintenance history

  • In 2008, the code for this project started out on PK Hack as a Windows screensaver, written in C# by Mr. Accident. Mr. Accident's source code has been published here.
  • In 2010, gjtorikian ported Mr. Accident's Windows screensaver from C# to Java to support Android Live screensavers.
  • In 2013, gjtorikian ported his own project from Java to ECMAScript 5 to support all devices with a web browser. He is well aware that his port is terrible (in fact, he even wrote a dedicated section in his README.md, just to reflect that).
  • In 2016, kdex rewrote the latter in ES2015+ for it to stay maintainable.
  • In 2017, gjtorikian copy-and-pasted kdex's source code into his repository.
  • In 2021, I updated the codebase to use Rollup and removed/replaced some old dependencies to keep the project maintainable as was kdex's vision.
  • In 2025, I migrated the codebase to Vite, continuing kdex's original vision for a maintainable project (kdex has since left GitHub).