Pixel Art Grid
pixel_art_grid is an Elixir library for integer scaling of decoded pixel art.
Use it to enlarge sprites while preserving hard edges, or to recover a smaller
grid from an export made of identical pixel blocks.
Installation
Add the dependency in mix.exs:
{:pixel_art_grid, "~> 0.1.0"}
Usage
sprite = [[0, 2], [2, 0]]
preview = PixelArtGrid.enlarge(sprite, 2)
# [[0, 0, 2, 2], [0, 0, 2, 2], [2, 2, 0, 0], [2, 2, 0, 0]]
PixelArtGrid.reduce(preview, 2)
# {:ok, [[0, 2], [2, 0]]}
PixelArtGrid.reduce([[0, 0], [0, 1]], 2)
# {:error, :non_uniform_block}
Features
- Scale rectangular grids of palette indices, RGB tuples, or other Elixir terms.
- Reduce uniform square blocks from the top-left of the grid using exact equality.
- Report dimensions that do not divide evenly by the scale factor.
Pass a nonempty rectangular grid and a positive integer factor. Image decoding, encoding, and palette conversion belong to the caller. Requires Elixir 1.12 or later and has no package dependencies. MIT license.
Related link
PicVane Pixel Art Generator is a browser tool for turning photos into pixel art. This library operates locally on pixel grids you supply.