Changeset - 9bc5e908c361
[Not reviewed]
default
0 1 0
David McClosky - 20 years ago 2005-06-16 22:26:17
dmcc@bigasterisk.com
Submasters have consistent repr(), new cmp and hash functions
1 file changed with 7 insertions and 1 deletions:
0 comments (0 inline, 0 general)
light9/Submaster.py
Show inline comments
 
@@ -60,13 +60,15 @@ class Submaster:
 
        return Submaster("%s*%s" % (self.name, scalar), 
 
            dict_scale(self.levels, scalar), temporary=1)
 
    __rmul__ = __mul__
 
    def max(self, *othersubs):
 
        return sub_maxes(self, *othersubs)
 
    def __repr__(self):
 
        levels = ' '.join(["%s:%.2f" % item for item in self.levels.items()])
 
        items = self.levels.items()
 
        items.sort()
 
        levels = ' '.join(["%s:%.2f" % item for item in items])
 
        return "<'%s': [%s]>" % (self.name, levels)
 
    def get_dmx_list(self):
 
        leveldict = self.get_levels() # gets levels of sub contents
 

	
 
        levels = [0] * 68
 
        for k, v in leveldict.items():
 
@@ -106,12 +108,16 @@ class Submaster:
 
            xfaded_sub.set_level(k, 
 
                                 linear_fade(self.levels.get(k, 0),
 
                                             otherlevels.get(k, 0),
 
                                             amount))
 

	
 
        return xfaded_sub
 
    def __cmp__(self, other):
 
        return cmp(repr(self), repr(other))
 
    def __hash__(self):
 
        return hash(repr(self))
 
                                            
 
def linear_fade(start, end, amount):
 
    """Fades between two floats by an amount.  amount is a float between
 
    0 and 1.  If amount is 0, it will return the start value.  If it is 1,
 
    the end value will be returned."""
 
    level = start + (amount * (end - start))
0 comments (0 inline, 0 general)