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%
love to see the classic «repeated diagonal brick» from gb pokemon!
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:
https://notes.yip.pe/notes/notes/A%20taxonomy%20of%204x4%20patterns%20Thread.html
As a zx81 fan & programmer, I see mazes, space ships and a ton of beatifull shapes...
Thanks, I always learn a lot from your code!
Nice work! I'm wondering what the letters are about (e.g.,803C)
these letters are actually numbers! the hexadecimal number 8017 is more compact than 32791, both being much shorter than the binary form 1111101010001 which represents pixels on and off in the fill pattern
resources:
https://www.lexaloffle.com/dl/docs/pico-8_manual.html#FILLP
https://mboffin.itch.io/pico8-fill-patterns
https://seansleblanc.itch.io/pico-8-fillp-tool
[Please log in to post a comment]