Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/10maurycy10/wfc
A toy wave function collapse implementation.
https://github.com/10maurycy10/wfc
Last synced: 2 months ago
JSON representation
A toy wave function collapse implementation.
- Host: GitHub
- URL: https://github.com/10maurycy10/wfc
- Owner: 10maurycy10
- License: gpl-3.0
- Created: 2022-08-08T20:19:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-03T23:13:49.000Z (6 months ago)
- Last Synced: 2024-10-31T11:40:44.737Z (3 months ago)
- Language: Rust
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Yet Another Wave Function Collapse implementation
Toy rust lubrary to create images based on paterns extracted from example data.
Example usage:
```rust
use image::io::Reader as ImageReader;
use image::RgbImage;
use yawfc::overlapping::overlapping;let generated_size = 30;
// Read the example image
let img = ImageReader::open("in.png").unwrap().decode().unwrap().to_rgb8();
let img:Vec> = img.rows().map(|x| x.map(|x| x.clone()).collect()).collect();// Create the wave function from example image.
let mut wave = overlapping(img, generated_size, generated_size, true, false, since_the_epoch.as_millis() as u64);// Collapse the wave function.
wave.colapse();// Extract image data from solver and save with image crate.
let mut tiles: Vec<_> = wave.get_collapsed_data().unwrap().iter().flatten().flat_map(|x| x.0).collect();
let generated = RgbImage::from_raw(generated_size as u32, generated_size as u32, tiles).unwrap();
generated.save("out.png").unwrap();
```