Skip to content

TehShrike/fantasy-map-generator

 
 

Repository files navigation

terrain.js

Minimal JavaScript fantasy map generator.

Author: Leonardo FLorez

Can be used as a plain script, or a Node.js module.

Script tag usage

In the browser, include d3 and terrain.min.js:

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.min.js">
</script>
<script src="terrain.min.js">
</script>

Optionally, a web worker may include terrain.worker.min.js, which attempts to be as tiny as possible, and does not include drawing functions (drawMap, colorMap)

// Generate a Map.
// terrain.generateMap(numberOfPoints, seedString, useSeed);
var aMap = terrain.generateMap(512, 'map!', false);

// Draw a map to a svg element.
// terrain.drawMap(svgElement, points, coast, rivers);
terrain.drawMap(svgElement, aMap.points, aMap.coast, aMap.rivers);

// Color a map inside a svg element.
// terrain.drawMap(svgElement, points, colorFn);
terrain.colorMap(svgElement, aMap.points, function(normalizedHeight){
    return 'gray';
});

Node.js usage

npm install fantasy-map-generator
// Generate a Map.
var terrain = require('fantasy-map-generator');
terrain.generateMap(512, 'map!', false);

Version notes

  • Version 0.0.1 initial release

License: MIT

Copyright 2017 Leonardo Florez.

About

minimal fantasy map generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%