Packages
pixel_art_grid
0.1.0
Scale pixel art grids and recover their original cells from uniform blocks.
Current section
Files
Jump to
Current section
Files
pixel_art_grid
README.md
README.md
# 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`:
```elixir
{:pixel_art_grid, "~> 0.1.0"}
```
## Usage
```elixir
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](https://picvane.com/image/ai-pixel-art-generator)
is a browser tool for turning photos into pixel art. This library operates
locally on pixel grids you supply.