19 releases (11 breaking)
0.12.1 | May 8, 2022 |
---|---|
0.12.0 | Feb 8, 2022 |
0.11.2 | Jul 28, 2021 |
0.11.0 | Feb 21, 2021 |
0.3.0 | Dec 30, 2018 |
#543 in Images
61 downloads per month
93KB
2.5K
SLoC
Wave Function Collapse for Image Files
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.
->
->
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.
->
Pass the flag --animate
to view a realtime animation of the image being generated:
Animate
This is a general tool for displaying in realtime, the generation of an image from a specified image file.
->
->
->
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
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
Dependencies
~5MB
~87K SLoC