Skip to content

About

Bounded PNG alpha masks, grid-cell projection and Tiled TMX/TMJ occupied-tile decoding for game art.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

78 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-tilemask

License: MIT Go


Bounded PNG alpha masks, grid-cell projection and Tiled TMX/TMJ occupied-tile decoding. Package tilemask, module github.com/Rethunk-Tech/go-tilemask.

Answers one question: which cells of an image, or which tiles of a map, are used. A cell is a square of a size the caller picks. A PNG becomes a one-bit-per-pixel mask (alpha not zero) that projects onto any grid, and a Tiled map becomes the occupied tiles of each top-level layer. Both decoders bound what their input claims (pixels, tiles, inflation) before allocating, so a few hostile bytes cannot ask for gigabytes. The caller bounds the input's byte size. Stdlib only.

Quick start

go get github.com/Rethunk-Tech/go-tilemask

A worked example and the contracts: HUMANS.md.

Features

  • A pixel is set when its alpha is not zero, at any bit depth; Mask.At and Mask.Cells read it.
  • Cells projects any region onto any cell size with floor division, so negative offsets land in negative cells. cell = 1 costs one byte per pixel while it runs.
  • 8-bit, non-interlaced PNGs take a fast path that skips what a mask does not need; everything else goes through image/png.
  • DecodeMap reads TMX and TMJ under one tile cap for the whole map, declared and decoded, and refuses a layer or chunk that holds more values than it declared.
  • WriteTo and ReadMask store a mask as a gzip file whose reader holds the header to the pixel cap.
  • Errors say why: ErrTooLarge, ErrUnsupported (zstd, unknown encodings) or ErrMalformed.

Documentation

Doc Audience
HUMANS.md Running and using the package
AGENTS.md Internals, invariants, and why
CONTRIBUTING.md Process — commits, tests, docs
SECURITY.md Vulnerability disclosure
CHANGELOG.md Release notes

License

MIT — see LICENSE. © 2026 Rethunk.Tech, LLC.

About

Bounded PNG alpha masks, grid-cell projection and Tiled TMX/TMJ occupied-tile decoding for game art.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages