#procedural-generation #heightmap #diamond-square #generate #algorithm #2d-array #heightmaps

ds-heightmap

Using diamond-square algorithm to generate heightmaps which stored in a 2D-array

5 releases

0.2.1 Jun 4, 2023
0.2.0 Jun 4, 2023
0.1.2 Jul 24, 2022
0.1.1 Jun 15, 2022
0.1.0 May 10, 2022

#3 in #heightmap

32 downloads per month

MIT license

12KB
248 lines

ds-heightmap

Latest version Documentation MIT

Build

Build for Web

Install wasm-pack and build:

wasm-pack build --release

Usage

use ds_heightmap::Runner;

fn main() {
    let mut runner = Runner::new();
    let output = runner.ds();

    println!("data: {:?}", output.data);
    println!("max: {}", output.max);
    println!("min: {}", output.min);
}

If you would like to supply a random number generator:

use ds_heightmap::Runner;
use rand_chacha::{rand_core::SeedableRng, ChaCha8Rng};

fn main() {
    let mut rng = ChaCha8Rng::from_entropy();

    let mut runner = Runner::new();
    let output = runner.ds_with_rng(&mut rng);

    println!("data: {:?}", output.data);
    println!("max: {}", output.max);
    println!("min: {}", output.min);
}

Dependencies

~1–1.7MB
~28K SLoC