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

@mitchallen/svg-tile

v0.12.0

Published

SVG tile pattern generator

Readme

@mitchallen/svg-tile

SVG Tile Pattern Generator


Installation

$ npm init
$ npm install @mitchallen/svg-tile --save

Legend


Usage

Step 1. Create a new project

  • Create a new project
  • Install the package (see instructions above)

Step 2. Define an input file

Define an input file and save as ./input/source.svg:

The input file should be an SVG file that contains:

  • a style section
  • a defs section which defines all the tiles with ids

For example:

<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="1024" height="1024">
    <style>
        rect.tileBack1 {
            stroke: none;
            fill: black;
        }

        rect.tileBack2 {
            stroke: none;
            fill: white;
        }

        rect.background {
            stroke: none;
            fill: white;
        }

        path.pie1 {
            stroke: none;
            stroke-width: 1;
            fill: white;
            stroke-linecap: butt;
        }

        path.pie2 {
            stroke: none;
            stroke-width: 1;
            fill: black;
            stroke-linecap: butt;
        }
    </style>
    <defs>
        <g id="base1">
            <rect width="200" height="200" class="tileBack1" />
        </g>
        <g id="base2">
            <rect width="200" height="200" class="tileBack2" />
        </g>

        <g id="tile1A">
            <use href="#base1" />
            <path d="M200,100 A 100,100 0,0,0 100,200 L 200,200 Z" class="pie1" />
            <path d="M0,100 A 100,100 0,0,0 100,0 L 0,0 Z" class="pie1" />
        </g>
        <g id="tile2A">
            <use href="#base2" />
            <path d="M200,100 A 100,100 0,0,0 100,200 L 200,200 Z" class="pie2" />
            <path d="M0,100 A 100,100 0,0,0 100,0 L 0,0 Z" class="pie2" />
        </g>
        <g id="tile1B">
            <use href="#tile2A" transform="rotate(90,100,100)" />
        </g>
        <g id="tile2B">
            <use href="#tile1A" transform="rotate(90,100,100)" />
        </g>
    </defs>
</svg>

Step 3. Define a generator file

Define a generator file (index.js), passing in the names of the tiles to the tiles property.

The generator will alternate between the two sets of tiles.

let factory = require("@mitchallen/svg-tile")

let {
  generate,
  getSquareXY,
} = factory;

generate({
    sourceFile: './input/source.svg',
    targetFile: './output/square-tiles.svg',
    toolTips: true,
    width: 550,
    height: 550,
    tileSize: 200,
    columns: 10,
    rows: 10,
    getXY: getSquareXY,
    tiles: [
      ['tile1A', 'tile1B'],
      ['tile2A', 'tile2B'],
    ],
    boardTransform: `translate(25,25) scale(0.25, 0.25)`,
    backgroundColor: 'black',
  })

Step 4. Run the file and generate a tiled SVG

Run the file and then open the output file (./output/...)

node index.js

open ./output/*.svg

Step 5. Use the generateLegend function to generate a tile legend SVG file:

  // generate legend
  let margin = 25;
  let padding = 30
  let tileSize = 200
  let columns = 2
  let rows = 2
  let width = margin * 2 + tileSize * columns + padding * (columns - 1)
  let height = margin * 2 + tileSize * rows + padding * (rows - 1)
  generateLegend({
    sourceFile: './input/source.svg',
    targetFile: './output/legend-01.svg',
    toolTips: true,
    width,
    height,
    padding,
    tileSize,
    columns,
    rows,
    getXY: getSquareXY,
    tiles: ['tile1A', 'tile1B','tile2A', 'tile2B'],
    boardTransform: `translate(${margin},${margin}) scale(1.0, 1.0)`,
    backgroundColor: 'gray',
  })