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

overprint

v0.8.4

Published

A JavaScript toolkit for rendering grids and maps

Downloads

15

Readme

Overprint

Overprint is a minimalist toolkit for rendering cell grids and tile maps using the HTML Canvas API.

It’s intended to be useful for visualizing discrete simulations, cellular automata, abstract/fantasy procedural map generation and 2D game development with an old-school flavour.

Status

npm travis

Install

With NPM CLI:

npm install --save overprint

Basic Usage

The following example illustrates the main features of the API.

import { TextGrid, Cell } from "overprint"

// Find or create an HTML canvas element in the DOM
// eg: <canvas id="demo"></canvas>
const canvas = document.querySelector("#demo")

// Create a default text grid from the canvas element
const grid = new TextGrid(canvas)

// Predefine a map of cell objects representing text characters
// with foreground and background colors
const Cells = {
  Grass: Cell(".", "#37CC63", "#2F3D33"),
  Sapling: Cell("^", "#A09A2C", "#2F3D33"),
  Tree: Cell("↑", "#337C22", "#2F3D33")
}

// Fill the entire grid
grid.fill(Cells.Grass)

// Render the filled cells to the canvas
grid.render()

// Overwrite a bunch of cells in random positions
for (let x,y,s=0; s<10; s++) {
  x = Math.floor(Math.random() * grid.width) - 1
  y = Math.floor(Math.random() * grid.height) - 1
  grid.writeCell(x, y, Math.random() > 0.5 ? Cells.Sapling : Cells.Tree)
}

// Re-render the cells that changed since the previous render
grid.render()

Credits

Overprint is a little library by Mark Rickerby.

Several of the ideas in this codebase were heavily influenced by Malison by Bob Nystrom and rot.js by Ondřej Žára. If you’re at all interested in browser-based roguelike games, you should check out their work—it’s awesome.

Also thanks to Amit Patel at Red Blob Games whose grid geometry resources saved me a whole heap of time that would have otherwise been spent scrabbling and scratching on graph paper and scrolling through verbose Wikipedia pages.

License

See the LICENSE file packaged with this software distribution.