Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ldd/fantasy-map-generator
Minimal fantasy map generator
https://github.com/ldd/fantasy-map-generator
Last synced: about 2 months ago
JSON representation
Minimal fantasy map generator
- Host: GitHub
- URL: https://github.com/ldd/fantasy-map-generator
- Owner: ldd
- License: other
- Created: 2017-02-28T16:32:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-12T01:50:20.000Z (over 7 years ago)
- Last Synced: 2024-09-15T23:18:14.274Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 99.6 KB
- Stars: 15
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
terrain.js
=============Minimal JavaScript fantasy map generator.
![fantasy map example](https://user-images.githubusercontent.com/1187476/30304277-a1880070-973a-11e7-938f-1008f0409132.png)
See the [demo](https://ldd.github.io/fantasy-map-generator/).
![fantasy map slideshow](https://user-images.githubusercontent.com/1187476/30303900-933e8644-9738-11e7-8f3d-bea3340f8986.gif)
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`:```html
```
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`)
```js
// 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);
var svgElement = d3.select('#mesh');
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
``````js
// Generate a Map.
var terrain = require('fantasy-map-generator');
terrain.generateMap(512, 'map!', false);
```Version notes
-------------
* Add an image and a slideshow to the `README`
* Version 0.0.3
* Fix adding `web` and `webWorker` builds, ignored by `.npmignore`
* Version 0.0.2
* Add getting svg example in the `README`
* Save to png in the demo (`gh-pages` branch)
* Add `web` and `webWorker` builds (`npm-module` branch)* Version 0.0.1 initial release
License: MITCopyright 2017 Leonardo Florez.