“When I cry, I see millions of circles.” – Bob Mould, “Circles”

It was supposed to be so easy. KDE has an application launcher that also shows your user account picture (“avatar”). A user submitted a “wishlist” bug to have the normally square avatar cropped to a circle, which would better match other aspects of the interface. Fair enough, I thought. I can handle this.

I did a small amount of research and found the technique for cutting out a circle. I got this:

Nifty. A circle.

Reviewers check it out and say,

“Hey, that looks great!”

So I’m pleased. Wasn’t that hard. Cutting out the circle was done in a slightly odd way, but it worked.

Then, a few moments later, another reviewer:

“You know what would be even better? If the circle had a ring around it.”

It’s common for the review process to take several passes, with changes, tweaks, corrections, additions, subtractions, etc. So I open my code editor and take a stab at adding a contrasting-color circle around the avatar. I end up with:

Again, looks pretty cool. The frame was a good idea. It contrasts nicely against the background.

Then someone points out

“The circle is not very smooth; you can make out all the pixels.”

Which, upon close inspection, is true. It’s jagged around the edges instead of smooth. The problem is called aliasing, so the fix for it is known as anti-aliasing.  The general principle involves adding extra pixels that are a sort of average between the color being drawn, and the background color. This image from Wikipedia shows the same letter, with and without anti-aliasing. How exactly the anti-aliasing is computed is, like, dude, way complicated. But this should show you the difference.

So I spend a chunk of time looking for some way to enable anti-aliasing in the software we use. Not having much luck. My circle is still being drawn with just the one color, so it’s ugly and jagged.

Then someone says,

“Hey, why don’t you re-use the method Programmer A used for Project B?”

So I scrap what I’ve done and go digging elsewhere in the source code. The technique is far more advanced and difficult to understand, but it generates a great result:

The circle is now nice and smooth. I post the updated code for people to review.

It doesn’t take long for someone to find a new problem.

“I went into System Settings and changed my avatar. Now all I have is a blank circle.”

I try it for myself. Sure enough, my lovely round avatar and anti-aliased circle has become:

And it won’t update until you log out and log back in. I check the file(s) that hold the user avatar. They’re changing immediately when a new avatar is selected. And the fancy circle code obviously notices the change, because it’s blanked out the old avatar.

I spend an ungodly amount of time trying to find some kind of “force-refresh” function, but can’t.

I ask Programmer A for help, since he coded this. He’s a very talented, very senior developer. And overall, a pretty good guy. But his team is crunching towards a deadline, and this is small, small, stuff by comparison.

Another very senior programmer comments on my dilemma, saying,

“I had problems trying to use Programmer A’s technique on a different project. Have you tried [the technique I originally tried]?”

While I’m waiting for some guru intervention, I unearth my old code, rewrite bits of it, and get a good results – a smooth circle, but without Programmer A’s tricky code. It looks just like this:

Which makes me say AWESOME to myself. This code is easier to read and change, so I tidy everything up and do some testing.

I change my avatar in System Settings. And the result is…

A goddamned blank circle. Again. Two totally different techniques, same problem.

I started on this about 9 days ago. Lots of trial and error. Two radically different drawing techniques. But still the same problem.

I need a guru, but the gurus are preoccupied and/or in distant time zones. I’ve got no choice but to wait for someone who knows the innards of the system to join the party.

In the meantime, I’ve grown to dislike circles immensely. It’s a little irrational to hate a geometric shape, but I’m really starting to hate circles.

Except these circles, which are great. Enjoy.


Leave a Reply

Your email address will not be published. Required fields are marked *