Just playing around with Voronoi diagrams.
The goal is to create something similar to what is described in the article Polygonal Map Generation for Games
go get github.com/peterhellberg/karta/cmd/karta
I spend most of my time in iTerm 2 and this project is no different.
This is how I preview the map in a split pane:
rerun -p "**/*.go" -c -x -b -- \
"go run cmd/karta/main.go -width 55 -height 55 && aimg -w 55 karta.png"
The project includes two binaries karta
and karta-server
, the latter serving both PNG and JPEG.
Usage of karta:
-count=2048: The number of sites in the voronoi diagram
-height=512: The height of the map in pixels
-iterations=1: The number of iterations of Lloyd's algorithm to run (max 16)
-output="karta.png": Output filename
-seed=3: The starting seed for the map generator
-show=false: Show generated map using Preview.app
-width=512: The width of the map in pixels
- s - size
- w - width
- h - height
- c - count
- i - iterations
First i just plotted out random dots:
Then drew a voroni diagram:
Found the centroids:
Ran the diagram through Lloyd's algorithm:
A few iterations later:
Animating 0-16 iterations:
Started coloring the map according to the distance from the center:
Added some randomness:
Added a different types of elevation:
Removed the centroid markers:
Started working on using Simplex noise for island shape and elevation:
Elevation based on noise + distance from center of map:
Tweaked noise and yellow beaches:
The MIT License (MIT)
Copyright (C) 2014 Peter Hellberg
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.