Skip to main content

A Hitomezashi Maker

08 Dec 2021 - Tags: pretty-pictures

It’s been a hot second since I’ve done something artistic, and a recent numberphile video gave me something small and simple to do! Plus, a really close friend of mine is a talented fibre artist, and since this type of artwork (hitomezashi) is originally a kind of decorative mending, I thought it would be fun to code this up and send it to her! It makes a great demo even without the fibre background, and I hope you all have fun playing with it ^_^.

It’s probably worth watching the video first, as otherwise it won’t make a ton of sense what this is doing, but the idea is pretty simple: You turn a pair of bitstrings into a pattern by reading a \$0\$ as “start at the edge” and a \$1\$ as “start off the edge”. You can input your own bitstrings (or words, which we can convert to bitstrings), or you can pick random bitstrings, where you can set the vertical or horizontal probability of choosing a \$0\$ or a \$1\$ in any given position in the string.

It turns out the regions you build in this way are always \$2\$-colorable, which is a cute exercise that they bring up in the video. The proof follows pretty quickly once you make the right observation, and I encourage you to give it a go! In addition to the choice of bitsring, I’ve added a slightly more nuanced way you can show your artistry by adding an option to choose the \$2\$ colors that get used!

Apologies in advance that this is a bit slow, haha. It turns out that making graphs in sage is really not the right tool for this! Still, this gets the job done ^_^.

Later on in the video, they switch over to an isoperimetric version of this idea, where they work with triangles instead of squares, and they have three input strings. Can you write code, analogous to the above, which lets people play around with this alternative approach?