Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fogleman/PirateMap
Procedurally generate pirate treasure maps.
https://github.com/fogleman/PirateMap
Last synced: 6 days ago
JSON representation
Procedurally generate pirate treasure maps.
- Host: GitHub
- URL: https://github.com/fogleman/PirateMap
- Owner: fogleman
- Created: 2015-12-10T22:20:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-21T02:14:31.000Z (almost 4 years ago)
- Last Synced: 2024-08-01T20:48:27.607Z (3 months ago)
- Language: Python
- Size: 13.7 KB
- Stars: 263
- Watchers: 11
- Forks: 25
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Pirate Maps
Procedurally generated pirate treasure maps. X marks the spot!
![Example](http://i.imgur.com/9c0RMuj.png)
### Dependencies
I used several excellent third party libraries...
- `cairo` for rendering
- `colour` for color interpolation
- `noise` for simplex noise
- `Pillow` for saving debug images of noise layers
- `pyhull` for delaunay triangulation
- `Shapely` for all kinds of 2D geometry operations### How to Run
The script will generate several random maps and save them as PNG files.
git clone https://github.com/fogleman/PirateMap.git
cd PirateMap
pip install -r requirements.txt
python main.py### How it Works
It took me a while to decide on an approach for generating the land masses. I didn't want to just generate some simplex noise, threshold it and render it. I wanted to actually compute a polygonal shape that I could do further operations on. So here's how that works...
- generate a layer of simplex noise with several octaves, with decreasing values as the edge of the image is approached
- fill the screen with randomly positioned points evenly spaced using the poisson disc algorithm
- filter the poisson points to those where the corresponding noise value is above some threshold
- take these points and compute a "concave" hull or alpha shape with themShapely's `buffer` function is used heavily for padding or cleaning up shapes.
I also wrote an `xkcdify` function to add some perturbations to some of the polygons, namely the different water color gradations.