项目作者: lebesnec

项目描述 :
Island map generator in JavaScript
高级语言: JavaScript
项目地址: git://github.com/lebesnec/island.js.git
创建时间: 2014-04-09T14:01:21Z
项目社区:https://github.com/lebesnec/island.js

开源协议:MIT License

下载


No Maintenance Intended

island.js

Island map generator in JavaScript, using a Voronoi graph and perlin noise http://lebesnec.github.io/island.js

Usage :

  1. <canvas id="island" resize="true"></canvas></canvas>
  2. <canvas id="perlin" hidden="true"></canvas>
  3. <script type="application/javascript">
  4. paper.install(window);
  5. window.onload = function(e) {
  6. paper.setup('island');
  7. Island.init();
  8. };
  9. </script>

You can also set the following optionals parameters :

  1. Island.init({
  2. width: 500,
  3. height: 500,
  4. perlinWidth: 256,
  5. perlinHeight: 256,
  6. allowDebug: false, // if set to true, you can click on the map to enter "debug" mode. Warning : debug mode is slow to initialize, set to false for faster rendering.
  7. nbSites: 10000, // numbers of voronoi cell
  8. sitesDistribution: 'hexagon', // distribution of the site of the voronoi graph : random, square or hexagon
  9. sitesRandomisation: 80, // will move each site in a random way (in %), for the square or hexagon distribution to look more random
  10. nbGraphRelaxation: 0, // nb of time we apply the relaxation algo to the voronoi graph (slow !), for the random distribution to look less random
  11. cliffsThreshold: 0.15,
  12. lakesThreshold: 0.005, // lake elevation will increase by this value (* the river size) when a new river end inside
  13. nbRivers: (10000 / 200),
  14. maxRiversSize: 4,
  15. shading: 0.35,
  16. shadeOcean: true
  17. });

Demo :

Here : http://lebesnec.github.io/island.js/

Sample :

Rendering with 50000 polygons and 250 rivers :
example of generated island
example of generated island

With 10000 polygons, shading off :
example of generated island

Rendering using a “square” graph :
example of generated island