New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fantasy-map-generator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fantasy-map-generator

minimal fantasy map generator

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

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);
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
// Generate a Map.
var terrain = require('fantasy-map-generator');
terrain.generateMap(512, 'map!', false);

Version notes

  • 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: MIT

Copyright 2017 Leonardo Florez.

Keywords

FAQs

Package last updated on 01 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc