Friday, February 23, 2007

Standard Gems: colorsys

Lots of us do color work. Maybe you're writing a full-fledged Photoshop killer, or you just want a utility to do some bulk conversions or color scheme generations. Well, in any case, you might find the often-forgotten colorsys module handy.

You can easily convert between different color component systems with these included functions:

hls_to_rgb(h, l, s)
hsv_to_rgb(h, s, v)
rgb_to_hls(r, g, b)
rgb_to_hsv(r, g, b)
rgb_to_yiq(r, g, b)
yiq_to_rgb(y, i, q)

No comments:

I write here about programming, how to program better, things I think are neat and are related to programming. I might write other things at my personal website.

I am happily employed by the excellent Caktus Group, located in beautiful and friendly Carrboro, NC, where I work with Python, Django, and Javascript.

Blog Archive