Yesterday I discovered this tweet from Martin Kleppe, which introduces the tixy.land website:
The idea is quite fun: basically, you can write a math expression that depends only on 4 variables (t,i,x,y) (hence the name of the web page), and the expression is rendered as animated dots located on a 16x16 grid, by applying simple rendering rules. Like this (example taken from the website):
The goal is then to provide a math expression that renders the “best” possible animation. And as the expression can be encoded directly in the URL, you can share it with others.
That’s pretty cool!
The idea pleased me a lot, and I decided to give a try. To make my tests easier, I’ve recoded a G’MIC command that renders the same kind of animation than the tixy.land website. This command is usable from the CLI interface
gmic of G’MIC, and should be available after a stdlib update, if you use G’MIC 2.9.0+ (so
$ gmic up and you’re ready).
The command allows you to save a
.avi file corresponding to the animation, and is able to export the specified expression directly as a tixy.land URL.
My first attempt:
I wanted to do something quite complex, so I didn’t try to respect the 32 chars limit.
What I did is take the
heart binary shape (G’MIC command
shape_heart), resized it to 16x16 and applied the DCT.
Then I filtered the DCT coefficients to keep only those with a high magnitude. As a result, I got an analytic expression, as a sum of weighted cosines, which renders an approximation of the heart binary shape. I finally added the (allowed) time variable
t in some of the cosines (those with the lowest coefficients), to generate an animation of a beating heart.
Here is the expression I ended up with:
expr = cos(0.4*x-0.2)+0.3*cos(0.8*x-0.4)-cos(0.2*y-0.1)-0.7*cos(0.4*x-0.2)*cos(0.2*y-0.1)+0.7*cos(0.8*x-0.4)*cos(0.2*y-0.1)+1.7*cos(0.4*y-0.2)-0.3*cos(0.4*x-0.2+3*t)*cos(0.4*y-0.2-t)+0.7*cos(0.6*y-0.3)+0.6*cos(0.4*x-0.2)*cos(0.6*y-0.3)+0.3*cos(0.8*x-0.4+t)*cos(0.6*y-0.3)+0.5*cos(0.8*y-0.4)+0.3*cos(1.2*x-0.6)*cos(0.8*y-0.4)+0.4*cos(y-0.5)-0.5*cos(0.8*x-0.4)*cos(y-0.5)-0.3*cos(1.6*x-0.8)*cos(1.2*y-0.6)-0.3*cos(0.8*x-0.4)*cos(1.6*y-0.8)
And here is the resulting animation:
What is nice is that you can see the same animation by visiting the following URL, redirecting to the tixy.land website:
That’s all for now, but I’m sure I will give another try in the future.
And you, what would you be able to achieve ?