Crates.io | billow |
lib.rs | billow |
version | 0.2.0 |
source | src |
created_at | 2022-09-02 16:57:36.246424 |
updated_at | 2022-09-02 22:06:54.249782 |
description | Simple Wave Function Collapse implementation in Rust |
homepage | |
repository | https://github.com/mrmarble/billow |
max_upload_size | |
id | 657478 |
size | 2,866,850 |
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.
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.