I saw a nice Facebook post by Keith Elliott Peterson about transforming a text string into a Truchet Tiling. He demonstrated the transformation by a nice animation you see above. Can you figure out the exact method he used just by watching the animation? It could take a bit but it is pretty simple. You can pause the video below to observe the details of the puzzle. Read further to see the answer. I thought it’d be pretty easy to demo with Wolfram Language.
The answer
The transformation uses first ASCII to go from text to binary and then a specific rule to go form 0s and 1s to Truchet Tiling. ASCII Conversion Chart looks like the below (this is only part of it):
The decimal number in Wolfram Language is obtained as
In[]:=
ToCharacterCode["h"]
Out[]=
{104}
which is further converted to its binary from (base 2):
In[]:=
IntegerString[104,2]
Out[]=
1101000
Note in the chart binary numbers are padded with zeros on the left to always have 8 digit. Let’s do this for the whole string “hello world”, which gives us a matrix or grid:
To go from 0s and 1s to Truchet Tiling we need first to realize that there are 4 distinct types of tiles. They can be easily depicted by placing quarter-circles into the diagonal corners of a square with the opposite background color:
The final observation is that type of tile depends not only on whether it is 0 or 1, but also if the sum of indexes of the digits in matrix a is even or odd. In other words the rules of transformation follow Checkerboard pattern:
The transformation can be also reversed. Can you write a function that takes an image and returns the text? Or maybe you have thoughts on simplifying my function? PLease do share in the comments.