Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/maartengr/sprite-generator
- Owner: MaartenGr
- Created: 2020-04-29T11:00:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-22T05:59:56.000Z (almost 2 years ago)
- Last Synced: 2023-03-03T07:59:08.660Z (over 1 year ago)
- Topics: pixel, pixel-art, procedural-generation, sprite-generator, sprites
- Language: Jupyter Notebook
- Homepage:
- Size: 206 KB
- Stars: 12
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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_canvasrobot = [[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))
```