9-Patch Quilt Generator

Construction

Each block in the quilt is composed using 9 shapes arranged in a 3x3 grid, such that the block is rotationally symmetric.

The shapes are selected from the following set of 16 primitives.

The centre shape has to be rotationally symmetric, so it must be one of the first four. Then we need a corner and an edge shape, which can be any of the 16. The corner and edge shapes are rotated by 90 degrees each time until we have a full block.

Taking inspiration from Jared Tarbell's nine.block, note that we can represent each possible shape using a 14-bit binary number.

We can then generate random patterns by choosing integers between 0 and 16,384. Some integers will produce duplicate patterns because the first four primitives are rotationally symmetric, in which case the first four bits will have no effect.

If we filter out these duplicates, we end up with 10,816 possible unique patterns.

Further Reading

Built with D3.