Giter Club home page Giter Club logo

piratemap's Introduction

Pirate Maps

Procedurally generated pirate treasure maps. X marks the spot!

Example

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 them

Shapely'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.

piratemap's People

Contributors

fogleman avatar jaredhalpern avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.