• Stars
    star
    211
  • Rank 186,867 (Top 4 %)
  • Language
    JavaScript
  • Created about 13 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A random fractal terrain generator in JavaScript

Random fractal terrain generator

Online demo: http://qiao.github.com/fractal-terrain-generator/demo/

This program is based on the Diamond-Square algorithm.
You may check out http://gameprogrammer.com/fractal.html for a detailed description.

Usage

Download http://qiao.github.com/fractal-terrain-generator/lib/terrain.js and include it in your html.

<script type="text/javascript" src="./terrain.js"></script>

Then, in your script:

var terrain = generateTerrain(32, 32, 1.0);

generateTerrain receives three parameters:

  • width: width of the terrain.
  • height: height of the terrain.
  • smoothness: smoothness of the terrain. Higher this value, smoother the terrain. default value is 1.

The result terrain will be a (width + 1) × (height + 1) two-dimensional array containing the elevation of each vertex.

License

MIT License

© 2011-2012 Xueqiao Xu <[email protected]>

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.

More Repositories

1

PathFinding.js

A comprehensive path-finding library for grid based games
JavaScript
8,389
star
2

euphony

MIDI visualizer in WebGL
JavaScript
845
star
3

difflib.js

Text diff library in JavaScript, ported from Python's difflib module.
CoffeeScript
246
star
4

sicp-solutions

My solutions to Structure and Interpretation of Computer Programs
Scheme
240
star
5

ces.js

Component-Entity-System framework for JavaScript games.
JavaScript
185
star
6

heap.js

A binary heap implementation in CoffeeScript/JavaScript.
CoffeeScript
125
star
7

ProgressCircle.js

A progress indicator in HTML5 canvas
JavaScript
114
star
8

coffee-box

A blog engine built upon Node.js, Express, MongoDB and CoffeeScript.
JavaScript
71
star
9

fingertree.js

Implementation of Finger Tree in JavaScript.
JavaScript
45
star
10

visual.js

JavaScript 3D library for dummies
JavaScript
32
star
11

mdwatch

Preview markdown document with live updates
JavaScript
25
star
12

vimfiles

My vim plugins and configuration
Vim Script
23
star
13

javascript-playground

A collection of my toy codes when I just started to learn javascript.
JavaScript
21
star
14

r7rs.js

R7RS compliant Scheme implementation in JavaScript (Work in Progress)
JavaScript
18
star
15

immutable-sequence.js

High performance implementation of Immutable Sequence in JavaScript, based on Finger Tree.
JavaScript
16
star
16

typedef.me

My blog at http://typedef.me in Ruby on Rails. (Deprecated)
Ruby
9
star
17

GR-JSON-Reader

Reader for exported Google Reader JSON files
Python
6
star
18

clando

A command-line todo list manager for minimalists
Common Lisp
2
star
19

scroll-progress

A small chrome extension showing the scroll progress of current page.
JavaScript
2
star