changeset 231:2c02748847f0

refactor gradient() from dmxchanedit
author drewp@bigasterisk.com
date Sun, 05 Jun 2005 07:28:50 +0000
parents b7095e4a6c43
children 6862f0b57b7a
files light9/dmxchanedit.py
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/light9/dmxchanedit.py	Sun Jun 05 07:04:34 2005 +0000
+++ b/light9/dmxchanedit.py	Sun Jun 05 07:28:50 2005 +0000
@@ -17,6 +17,12 @@
 import tkFont
 # see replacement stdfont below
 
+
+def gradient(lev, low=(80,80,180), high=(255,55,50)):
+     out = [int(l+lev*(h-l)) for h,l in zip(high,low)]
+     col="#%02X%02X%02X" % tuple(out)
+     return col
+
 class Onelevel(tk.Frame):
     """a name/level pair"""
     def __init__(self, parent, channelnum):
@@ -82,11 +88,7 @@
         """color the level label based on its own text (which is 0..100)"""
         txt=self.level_lab['text'] or "0"
         lev=float(txt)/100
-        low=(80,80,180)
-        high=(255,55,050)
-        out = [int(l+lev*(h-l)) for h,l in zip(high,low)]
-        col="#%02X%02X%02X" % tuple(out)
-        self.level_lab.config(bg=col)
+        self.level_lab.config(bg=gradient(lev))
 
     def setlevel(self,newlev):
         """the main program is telling us to change our