Skip to content

cgiffard/DiamondSquare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

DiamondSquare

It's like... autogenerated heightmaps for your projects, man.

DiamondSquare based Heightmap

Example

	var myInitMap = [	4,1,2,4,
						1,4,2,2,
						3,2,1,6,
						2,1,1,5	];
	
	// Create a new DiamondSquare algorithm from the initial map, with a random
	// roughness factor
	var ds = new DiamondSquare(myInitMap,4,4,Math.random()*10);
	
	
	// Iterate until you're satisfied. The map doubles in size with each
	// iteration.
	ds.iterate();
	
	...
	
	ds.iterate();
	
	// Then the data you want is in:
	ds.dataStore;

There's a demonstration file that just renders the heightmap to canvas (with some rather buggy bilinear interpolation) but the intention is that you use it for geometry or something exciting like that!

About

Implementation of the diamond-square algorithm in JS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published