[Tkinter-discuss] Calculating a ripening tomato

Bob Greschke bob at passcal.nmt.edu
Tue Oct 18 18:15:25 CEST 2011


On Oct 18, 2011, at 00:19, Greg Ewing wrote:

> Bob Greschke wrote:
>> 2.7 being close to e. I should have known the "natural" log would be
>> involved somehow, even though most tomatoes these days are far from natural.
> 
> Resemblance to e probably doesn't have much to do with it --
> more likely your formula is just preventing the overall
> brightness of the colour from getting too low, thus
> avoiding brown.
> 
> Another way to approach this might be to do the interpolation
> in HSB space, varying the hue angle from red to green while
> keeping the brightness constant, and then convert to RGB.
> 
> -- 
> Greg

Oh, agreed.  That sounds like a better way to do this, but for a quick and dirty approach I messed for quite a while with just red and green rates and tossed in several different if-statements to mess with things here an there, but then just threw all of that out and tried the **2.7 and it all of a sudden was pretty close to what I had in mind.  I've since altered it to start with a bit of red

R = 65+(190-int((Pct**2.718)*190.0))
G = int(Pct*255.0)

It still spends a little too much time in a tanish-orangeish area for my taste, but it's good enough for this exercise.  I wouldn't dismiss e too quickly.  It pops up in some weird places.

Now I'm wondering about being able to calculate things like going from dark green through to white for land elevations, and the colors of the rainbow in the right order, light blue to dark blue for water depths (that one is easy), etc.  I'll have to look into this when I get some time.

Thanks!

Bob




More information about the Tkinter-discuss mailing list