dsquare 1.0.0-alpha

Implementation of the Diamond Square algorithm.

Released 2016-12-12.

To install, run:

haxelib install dsquare 1.0.0-alpha

See using Haxelib in Haxelib documentation for more information.

MaintainerDecatek
Websitehttps://github.com/degrav/dsquare/
Current version1.0.0-alpha
StatisticsInstalled 9 times
LicenseMIT
Tags

README.md

hxdsquare

Haxe implementation of the Diamond Square algorithm

Installation

You can install hxdsquare by using haxelib install hxdsquare.

Usage

This library provides a DiamondSquare object which will hold the generated vertices. You should be able to use this library with any graphic framework you want.

import dsquare.DiamondSquare;
import dsquare.geom.Vertex;
import dsquare.geom.Square;

class Example {

	var dsquare:DiamondSquare;
	var squares:Array<Square> = [];

	static var ITERATIONS:Int = 5;
	static var SIZE:Float = 1024;

	public function new() {
		var a0:Vertex = new Vertex(0, 0);
		var a1:Vertex = new Vertex(SIZE, 0);
		var a2:Vertex = new Vertex(SIZE, SIZE);
		var a3:Vertex = new Vertex(0, SIZE);
		var sq1 = new Square([a0, a1, a2, a3]);
		squares.push(sq1);

		dsquare = new DiamondSquare(sq1, 10);
		dsquare.gen(ITERATIONS);
	}
}

Alternatively, you can use the Square.fromArray function to create your squares.

Square.fromArray([0, 0, SIZE, 0, SIZE, SIZE, 0, SIZE]);

You then have to use the vertices provided by the dsquare object to use them.

function draw() {
	for(vert in dsquare.vertices) {
		drawVertex(vert); // You have to provide this function, dsquare does not provide any drawing tool.
	}
}

Issues

Feel free to open issues in this repository detailing any bug you find.

Contributions

Feel free to contribute to the project by opening a pull request or an issue detailing the feature you want to add/bug you want to fix.