Skip to content

startling/mask

Repository files navigation

mask

This is mask, a tiny MIT-licensed library providing collision masks and thus pixel-perfect collision detection in JavaScript. Collision masks are read from PBM files.

what's a PBM?

PBM is a minimalistic monochrome image format. One variant of it looks like this:

P1
10 10
0000000000
0111111110
0110000010
0101000010
0100110010
0100110010
0100001010
0100000110
0111111110
0000000000

There are a number of tools to make PBM images -- ImageMagick's convert tool will do it, and NetPBM provides a suite of confusing tools for working with it and its sister formats. You probably want something like pngtopnm < in.png | pamditherbw | pamtopnm > out.pbm.

cool, how do I use this?

You probably want Mask.PBM.url, Mask.collision, and Mask#within. There are some just-alright docs. The source is well-commented and not difficult; might as well take a look.

how can I help?

Pull requests are welcome; tests and jslint compliance are appreciated.

About

Collision masks from PBM files for JavaScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published