Colors

libavg has always supported specifying colors in html-like fashion: You pass a string of six hex digits, two each for the red, green and blue components of the color. That’s nice if you’re copying the code from Gimp or Photoshop, but it was quite limiting if you wanted to actually calculate colors or maybe interpolate between two colors.

So… there’s a shiny new Color class that can be constructed from a tuple and passed whereever color strings were expected before (of course, strings still work). Colors can be mixed and used in animations. Last but not least, I did some research on smart ways to mix colors. It turns out that a simple weighed average of the RGB components doesn’t look so good – for instance, mixing 50% red with 50% yellow results gives you gray. So libavg now mixes in CIE L’ch color space, which more-or-less preserves the saturation and looks pretty good.

As a result, you can now do this:

startColor = avg.Color("0000FF")
endColor = avg.Color("FFFF00")
for i in xrange(11):
    color = avg.Color.mix(startColor, endColor, 1-(i/10.))
    avg.RectNode(pos=(i*20,0), size=(20,20), fillcolor=color, 
            fillopacity=1.0, parent=rootNode)

to produce:

colors

More infos on color mixing are in this blog post.

Version 1.8 Released

I’ve just released version 1.8 of libavg. You can download it at the usual place.

This means that finally, all of the cool features that have been in the development version for a while are available in an easy-to-install package. The release includes a skinnable widget library, a unified event handling framework (see Cleaning up Messaging), and a much-improved App class by OXullo. Scotty added a very nice sample program called firebirds that showcases libavg development in a compact form, and Richy implemented a new logging framework. Rendering is much faster (see Speeding up Rendering), and I completely rewrote the video decoding subsystem (see Video Decoding using libav and ffmpeg). Lots of other things have been improved as well – see the NEWS file for details.

Lots of thanks to OXullo, Richy and Scotty for testing the release!