Regularly Expressional Fractalations
There’s something about fractals that humans find fascinating. They manage to contain a beautiful impression of infinity despite being not very difficult to create. These fractals have been produced by a very simple recipe:
- Split a big square of pixels into 4 quadrants and label them 1 to 4
- Repeat this process for each of the smaller squares and add the quadrant number to the label
- Keep cutting the squares into 4 until you’ve gone as small as you want
- Now we can use regular expressions to find and mark boxes with certain labels
I wrote a little bit of javascript that creates such fractals from regular expressions involving the digits 1, 2, 3 or 4. Have a play here and check out some examples below.