This is a little tool for viewing all possible 4x4 fill patterns, after removing duplicates which are the same pattern inverted, translated, rotated, or flipped in x/y/diagonally. There are 65536 possible raw fill patterns (1 << 16), but only 433 unique patterns once "equivalent" ones have been discarded.
To use a fill pattern that you like, prefix it with "0x" (it is a hexadecimal number) and pass it fillp():
fillp(0x95a6) circfill(64,64,40,0xacd) fillp() -- reset
Press UP and DOWN to browse the catalogue, [X] to invert and [O] (z/c) to hide the info bar.
I don't know if there is a more efficient way to calculate groups (or the number of groups) for these equivalence relations, but PICO-8 is more than fast enough to brute force it, so that's what this cartridge does! For each 16-bit fill pattern, its group id (the "orbit") is calculated by applying every combination of transformation and returning the lowest result. If that value not already found in the list of patterns, it is added.
I was able to take a few shortcuts though -- for example, calculating 90 degree rotations is not necessary, because for every orientation there is a combinations of flipping in x, y and through the diagonal (transpose) that is equivalent to that rotation.
Ha super helpful to quickly choose a pattern 👍
📈 Perfs note:
since search() is called in _draw() and the optimistic
stat(1)<.98 causes it to run most of the time at 15/30fps I've tweaked the cpu check at
stat(1)<.96 and it runs quite faster. Comparison: launching this <.98 one and immediately after the tweaked <.96, the latter reaches 100% while the other is still around 65%
Over on mastodon, @[email protected] directed me towards her taxonomy of 4x4 patterns, which uses the same symmetries to group patterns in interesting ways with cute names:
[Please log in to post a comment]