wfc_image

Crates.iowfc_image
lib.rswfc_image
version0.12.1
sourcesrc
created_at2018-12-27 07:47:39.540781
updated_at2022-05-08 06:13:02.547507
descriptionCreate patterns for wfc using image files
homepagehttps://github.com/gridbugs/wfc.git
repositoryhttps://github.com/gridbugs/wfc.git
max_upload_size
id104018
size49,732
Stephen Sherratt (gridbugs)

documentation

https://docs.rs/wfc_image

README

Wave Function Collapse for Image Files

Version Documentation

A helper for wfc to simplify generating images based on image files, using the image crate.

Examples

Most of the sample images are taken from mxgmn/WaveFunctionCollapse.

Simple

This example generates an output image which is similar to the input image.

Rooms Input -> Rooms Output1 Rooms Output2

Bricks Input -> Bricks Output1 Bricks Output2

Flowers

It's also possible to manually restrict the output to encode specific properties. In this example:

  • The bottom row of patterns is set to be ground.
  • A sprout pattern is placed in a random position along the bottom of the output.
  • Ground patterns are forbidden from being automatically chosen.
  • The flower pattern is forbidden to appear in the bottom few rows of output, to enforce a minimum height of flowers.

Flowers Input -> Flowers Output1 Flowers Output2

Pass the flag --animate to view a realtime animation of the image being generated:

Flowers Animation

Animate

This is a general tool for displaying in realtime, the generation of an image from a specified image file.

Link Input -> Link Animation

Sewers Input -> Sewers Animation

Cat Input -> cat Animation

cargo run --release --example=animate -- -i examples/cat.png -x100 -y60 -p3 --forever
cargo run --release --example=animate -- -i examples/flowers.png -x100 -y60 -p3 --all-orientations --forever

Anchor

Takes the tile in the bottom-right corner and forces it to appear along the entire bottom and right sides of the output, wrapping to the top and left sides. This is an easy way to prevent the output from wrapping. Optionally, the bottom-right corner tile (which is often blank) can be removed from the choices of tiles for other cells.

The point of this example is to easily experiment with generating levels for roguelikes.

By default the bottom-right corner tile is removed from the possibilities for other cells:

cargo run --release --example=anchor -- -a -i examples/cat.png -o /tmp/a.png -p3 -x100 -y100

cat maze

You can allow the bottom-right corner tile to appear in other tiles with the --allow-corner flag.

cargo run --release --example=anchor -- -a -i examples/cat.png -o /tmp/a.png -p3 -x100 -y100 --allow-corner

cat maze sparse

Commit count: 163

cargo fmt