calculate a colour gradient

Grégoire Dooms dooms at info.LESS.ucl.SPAM.ac.be
Thu Jun 17 15:22:42 EDT 2004


Mark Light wrote:
> Hi,
>    I have a tk.scale bar for which I want the background to change from
> blue to red as I slide along it. The mechanics of this I can do, but
> the colour gradient I have is very crude - basically the amount of R in
> RGB just increases whilst the G and B are fixed values. Whilst this is
> not really a python question does anybody have any suggestions about
> calculating the RGB values for a smooth colour gradient?

Have a look at the HSV color space and HSV -> RGB conversion:
http://en.wikipedia.org/wiki/HSV_color_space

Then linearly adjust the H while you slide the bar.

HTH,
--
Grégoire Dooms



More information about the Python-list mailing list