Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/maartengr/sprite-generator

Python procedural sprite generator
https://github.com/maartengr/sprite-generator

pixel pixel-art procedural-generation sprite-generator sprites

Last synced: 23 days ago
JSON representation

Python procedural sprite generator

Awesome Lists containing this project

README

        

Sprite Generator
======================

A python port of https://github.com/zfedoran/pixel-sprite-generator. It essentially
takes in any template and randomly generates sprites based on the template.

## Algorithm
The sprites are generated by using a two dimensional mask. The values in the mask are then randomized and mirrored. The resulting template is rendered to a canvas element.

The algorithm is explained in more detail on [Dave Bollinger's](http://web.archive.org/web/20080228054410/http://www.davebollinger.com/works/pixelspaceships/) website.

## Examples
**Spaceships**
![](images/spaceships.png)

**Robots**
![](images/robots.png)

**Dragons**
![](images/dragons.png)

**Dragons Top-Down**
![](images/dragons_top.png)

## Code
```python
from SpriteGenerator import generate_canvas

robot = [[0, 0, 0, 0],
[0, 1, 1, 1],
[0, 1, 2, 2],
[0, 0, 1, 2],
[0, 0, 0, 2],
[1, 1, 1, 2],
[0, 1, 1, 2],
[0, 0, 0, 2],
[0, 0, 0, 2],
[0, 1, 2, 2],
[1, 1, 0, 0]]

im = generate_canvas(robot,
color_variations=0.2,
brightness_noise=0.3,
edge_brightness=0.3,
saturation=0.2,
colored=False,
mirror=True,
n=80,
nr_columns=20)
im.resize((im.size[0]*2, im.size[1]*2))
```