dsquare

Implementation of the Diamond Square algorithm.
https://github.com/degrav/dsquare/

To install, run:

haxelib install dsquare 1.0.0-alpha 

See using Haxelib in Haxelib documentation for more information.

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.

Contributors
Decatek
Version
1.0.0-alpha
Published
1 year ago
License
MIT

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github