Skip to content
/ wfc-rs Public

Rust wrapper for the krychu/wfc implementation of Wave Function Collapse

Notifications You must be signed in to change notification settings

nsmryan/wfc-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WFC

The wfc-rs crate is a wrapper for the krychu/wfc implementation of Wave Function Collapse.

The wfc library is manually wrapped with extern functions, and a small, more ideomatic Rust wrapper is provided.

Note that this is an early, but working version.

Usage

Once the crate has been added to Cargo.toml as:

wfc_rs = "0.5"

create a WfcImage with from_vec or from_file:

let image = WfcImage::from_file("data/cave.png")?;

This creates an optional NonNull, which contains a pointer to the underlying WfcImage structure. This structure is a repr(C) struct that matches the 'wfc.h' structure 'wfc_image'.

and then a Wfc structure from this image, as well as the configuration settings:

    let mut wfc = Wfc::overlapping(32, 32, image, 3, 3, true, true, true, true)?;

With this Wfc, you can run an interation with 'run'

wfc.run();

and either export an input:

wfc.export("output.png");

or get the raw pixel data as a Vec:

let bytes = wfc.vec();

About

Rust wrapper for the krychu/wfc implementation of Wave Function Collapse

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published