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

@ayebear/pack

v1.2.2

Published

Simple, multi-threaded texture packer in Go

Downloads

18

Readme

pack

Simple, multi-threaded texture packer in Go

Native CLI Usage

Build

go build

Run

./pack -in=images -out=sheets -name=textures

For info on more flags, run:

./pack -h

JS Usage

Install

Yarn

yarn add --dev @ayebear/pack

NPM

npm i -D @ayebear/pack

Run

Run with JS wrapper (slower)

yarn run pack -h

Run natively (faster)

./node_modules/@ayebear/pack/pack -h

Client usage

Pixi.js v6

With static files

Pack outputs a single json file along with (potentially) multiple png files. A pixi.js plugin is included with pack, to load this json file and all associated images in parallel.

import { Loader } from '@pixi/loaders'
import { PackSpritesheetLoader } from '@ayebear/pack'

Loader.registerPlugin(PackSpritesheetLoader)
Loader.shared.add('images/textures.json').load(...)
With bundled files

If you'd like to avoid using static files, and want to "properly" bundle the images and metadata, you can use the loadSheets function. The imports for sheetData and sheets might look a bit different depending on your bundler - in this example, parcel v2 is being used:

import { Loader } from '@pixi/loaders'
import { loadSheets } from '@ayebear/pack'
import sheetData from 'sheets/textures.json'
import * as sheets from 'sheets/*.png'

// Globbing only gives the "*" part, but we need full path
// to match up with sheetData keys
const images = {}
for (const key in sheets) {
    images[`sheets/${key}.png`] = sheets[key]
}
loadSheets(Loader.shared, sheetData, images).load(...)

About

Pack doesn't do any complicated, slow, puzzle-fitting of sprites. It just bins sprites based on size into separate sprite sheets, in left-to-right grid order. It does this making balanced use of multi-threading to achieve very high performance.

Tested in a real-world project with 300+ sprites. Pack produced 10 sprite sheets in just ~65ms.