calculate a colour gradient

Scott David Daniels Scott.Daniels at Acm.Org
Fri Jun 18 21:58:45 CEST 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?
> 
> 
> Mark.

Depending on the purpose, you could: search for "color temperature"
or "black body radiation" to get a very defensible transition, or
(for false-color or some such), break the range into pieces and do
a linear interpolation inside each piece.  Play with R-O-Y-G-B, for
example.  Note: even intervals is not going to look right, eyeball
the boundaries.


-- 
-Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list