March 7, 2012 happens to be Piet Mondrian's 140th birthday!
For an engineer and a scientist, I'm probably more of an art lover than most. I studied art history a bit in college, and even worked for the art department at Texas A&M University, which earned me a few free art classes over my usual engineering workload. I generally seek out both boutique art galleries and the big ones when traveling. All that said, Piet Mondrian is one of my favorite artists. His lines, colors, proportions, precision, balance, symmetry and asymmetry speak to a part of my soul that's hard to explain.
You might recognize some of these, as his most recognizable works:
In the spirit of Google Doodles, I thought I'd call attention to Byobu's Piet Mondrian function quietly nestled in Byobu. If you're running byobu in tmux mode (which you can launch with byobu-tmux), then you can simply press ctrl-alt-F12 in most environments (my sympathies if you're off the beaten path). You should see something like this:
This is the output of the 116 line shell script found at /usr/lib/byobu/include/mondrian. I don't think I've ever narrated my source code in my blog before, but I reckon I will do so here. It's not that I'm particularly proud of the implementation or the code, but rather that I'd like to explain the algorithm I have applied to Mondrian's art :-)
- First, it hardcodes the color values of red, yellow, blue, and white from a 256 color palette. To do so, I used the color picker utility in gimp against Mondrian's Composition 10, 1939–1942.
- Next, it chooses some random number of rectangles between 10 and 40, which seemed to me to be fairly representative of most of Mondrian's geometric compositions.
- Then, from the randomly numbered rectangles, 3 are chosen -- 1 for red, 1 for yellow, and 1 for blue. I fully well appreciate that Mondrian put far more thought into what regions where colored, and which color, how much, with great precision and balance. I hope one day to decode his algorithm, but for now, my code simple chooses these at random.
- Now, tmux does a bit of the hard work for us, creating a new window in byobu, sets the background to our particular white, and splitting that window into a number of panes matching our randomly chosen amount.
- Finally, one pane each is colored red, yellow, and blue. Note that tmux does not support the classic UNIX terminal feature bce (background color erase), so instead, we use a one-line perl script to color each pane.