wfc 0.2.0

Generate images using Wave Function Collapse
Documentation

Wave Function Collapse for Image Files

A rust library for generating images which are similar to other images. Similar is defined as both:

  • strict locally similar: every small (typically 3x3) pattern in the output image appears somewhere in the input image.
  • loose globally similar: the distribution of small patterns in the output image is roughly the same as the distribution of small patterns in the input image.

This is based on https://github.com/mxgmn/WaveFunctionCollapse

Examples

Simple

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

Rooms Input -> Rooms Output1 Rooms Output2 Rooms Output3

Bricks Input -> Bricks Output1 Bricks Output2 Bricks Output3

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 Flowers Output3