Over the last couple of years, I’ve been involved with lots of side projects, both online and offline. Some of them, I’ve written about on the blog, like my music visualizer project. A few of them, got their own project page, like the website for my niece (but no blog post) while some didn’t even get a mention. I thought I’d write about the many-many side projects I’ve started (and abandoned). You might also wanna visit the /projects page for the larger projects.
June 2015 I wrote a script that scraped Tor’s serialized publication of the first book in Hoshruba series to generate EPUB and MOBI files. I would recommend the book if you are interested in reading what many would term the “original fantasy book”
March 2017 Attempted to transcribe the draft IT policies put up by the Government of Kerala. Lots of OCR followed by manual fixes. I stopped working on this when I realized that the government had actually put up a really nice website for this (with clear plaintext, not the bad PDF I was using as the source).
August 2015 I created a DNS based HTTP-3xx redirect service. Useful if you own a domain and you want it to be redirected, but don’t have a webserver with you. Made as part of the Django Hackathon organized by HackerEarth in Ruby.
Worked with transparency, but limited to bars visualization.
I decided to go ahead with Spectrumyzer (This is the default config):
The Traffic Jam
The very same day, stuck in a traffic jam1, I asked Vikalp for some color ideas on the visualization.
The obvious 2 were tried first:
It finally dawned on us to use the light blue variant with padding set to zero:
Here is one showing the actual positioning (set using the offsets):
With the padding set to zero, it already looked great. I ended up using this
as my wallpaper for the next one week. Vikalp wanted to make the bars
non-rectangular, and I spent some time figuring out how to make waveforms using
bezier curves2. The basic learning from my experiments were:
Cairo has methods for drawing cubic bezier curves.
Cubic bezier curves have 2 control points.
The control points must be symmetric (equidistant) as well as parallel to the origin points.
The parallel part ensures that the ending and starting line segments are always tangential giving a smooth joining.
This is roughly what you want to do when drawing waveforms:
The code I wrote picks the midpoints of the bars and then connects them using bezier curves:
# control point cords# Make sure these are symmetricc1x=rect_top_mid_x+16c2x=next_rect_top_mid_x-16c1y=rect_top_mid_yc2y=next_rect_top_mid_y
I also had to make the number of bars configurable (this is default=64, which doesn’t look great):
Here is the complete final result in HD:
What I learned
Bezier curves are not magic.
Drawing pixels on screen and filling them was quite easy with Cairo and Python.
Coding is wizardry. The things that I take for granted every day (take a multi-page website and get useful tabular data out of it, for eg) are unthinkable for most people. The idea of doing water waves was something I knew would be possible before I even looked at the codebase.
If you’d like to replicate this setup, or build upon it, here is my spectrum.conf file.
I also filed a PR (now merged!) to the spectrumyzer project adding support for curve based renders.