billow

Crates.iobillow
lib.rsbillow
version0.2.0
sourcesrc
created_at2022-09-02 16:57:36.246424
updated_at2022-09-02 22:06:54.249782
descriptionSimple Wave Function Collapse implementation in Rust
homepage
repositoryhttps://github.com/mrmarble/billow
max_upload_size
id657478
size2,866,850
Alvaro Tinoco (MrMarble)

documentation

README

Billow

Crates.io Billow documentation

Rust implementation of the wave function collapse algorithm. Based on Oskar Stålberg's and Martin Donald detailed explanation.

🚧 This is a work in progress.

Usage

This is a general purpose library, I provide implementations for the image::DynamicImage and bevy::prelude::Image types.

use billow::Wave;
use image::DynamicImage;

fn main() {
    let input: Vec<DynamicImage> = load_assets("assets/basic");
    let (width, height) = (20usize, 20usize);

    // New wave with a 20x20 grid
    let mut wave = Wave::new(input, width, height);

    // Populate the grid and choose a random starting point
    wave.initialize()

    // Run the algorithm.
    // This will try to collapse the grid to a single state.
    // `100` is the number of iterations.
    // each iteration will collapse one cell and try to propagate the changes.
    wave.collapse(100).expect("Failed to collapse");
}

See examples for more.

Commit count: 12

cargo fmt