The new Clerk header image is made from a fifth order Hilbert Curve, so we will first create a recursive function to generate Hilbert curves of arbitrary order.
These are the points for this curve:
But they're much more interesting if we use Clojure2D canvas to draw a path made from points to show the complete curve:
The trick to getting the effect we want is to apply a conformal mapping to the original Hilbert Curve to convert it into an 👁 shape in celebration of Clerk's viewers. We can do this by treating the original point coordinates as complex numbers, squaring them, then taking the real and imaginary portions of each of those complex numbers as the x and y coordinates of a new set of points. This is made especially easy because Clojure2D happens to include the author's Fastmath library. 🎉
What I find so special and enchanting about the mapping that we're using here is that it maintains the angle of intersection everywhere but (the origin). 📐
This is called a conformal map by mathematicians. 😍