Skip to content

Commit

Permalink
Fixes up a few problems with IncrementEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
erodozer committed Jun 27, 2011
1 parent 1acec4e commit acf0064
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/Rockmeter.py
Expand Up @@ -467,6 +467,7 @@ def updateRates(self):
def updateValues(self):
condition = bool(eval(self.condition))
if condition:
#slides to the end position
for i in range(len(self.start)):
if self.current[i] > self.end[i]:
if self.end[i] < self.start[i]:
Expand All @@ -478,7 +479,10 @@ def updateValues(self):
self.current[i] += self.rates[i]
else:
self.current[i] = self.end[i]
if self.counter >= 1.0:
self.current = self.end[:]
else:
#slides back to original position smoothly
if self.reverse:
for i in range(len(self.start)):
if self.current[i] > self.start[i]:
Expand All @@ -490,8 +494,10 @@ def updateValues(self):
if self.end[i] < self.start[i]:
self.current[i] += self.rates[i]
else:
self.current[i] = self.startCoord[i]
else:
self.current[i] = self.start[i]
if self.counter <= 0.0:
self.current = self.start[:]
else: #instant jump to starting value
self.current = self.start[:]
self.counter = 0.0

Expand All @@ -513,6 +519,12 @@ def updateCounter(self):
return False
return True

#basic updating for the effect
def update(self):
self.updateRates()
self.updateValues()
self.updateCounter()

#slides the layer from one spot to another
#in a set period of time when the condition is met
class Slide(IncrementEffect):
Expand Down Expand Up @@ -564,25 +576,26 @@ def __init__(self, layer, section):
#y position needs to be flipped initially
if isinstance(self.layer, FontLayer):
self.current[1] *= .75
self.current[1] = .75 - self.position[1]
self.current[1] = .75 - self.current[1]

self.reverse = bool(eval(self.getexpr("reverse", "True")))

def update(self):
def updateValues(self):
#reverse the processing for font layer handling
if isinstance(self.layer, FontLayer):
self.current[1] = .75 - self.current[1]
self.current[1] /= .75

self.updateRates()
self.updateValues()
self.updateCounter()

super(Slide, self).updateValues()

#because of the y position being flipped on fonts it needs to be caught
if isinstance(self.layer, FontLayer):
self.current[1] *= .75
self.current[1] = .75 - self.current[1]

def update(self):
super(Slide, self).update()

self.layer.position = self.current[:]

#fades the color of the layer between this color and its original
Expand Down Expand Up @@ -616,11 +629,9 @@ def __init__(self, layer, section):
self.reverse = bool(eval(self.getexpr("reverse", "True")))

def update(self):
self.updateRates()
self.updateValues()
self.updateCounter()
super(Fade, self).update()

self.layer.color = self.current
self.layer.color = self.current[:]

#replaces the image of the layer when the condition is met
class Replace(Effect):
Expand Down

0 comments on commit acf0064

Please sign in to comment.