Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/graphics
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2008-04-18 22:14:11 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2008-04-18 22:14:11 (GMT)
commit03e515b4630c69272f62dd4dd7ce71367a3f2e36 (patch)
tree6eeb7bdfeb54b137816325d9e287bd395e557c96 /sugar/graphics
parent4ad5928a740902bb49ecc0e16762826e0a1b967d (diff)
pylint animator
Diffstat (limited to 'sugar/graphics')
-rw-r--r--sugar/graphics/animator.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/sugar/graphics/animator.py b/sugar/graphics/animator.py
index 459851b..85b9852 100644
--- a/sugar/graphics/animator.py
+++ b/sugar/graphics/animator.py
@@ -28,13 +28,14 @@ class Animator(gobject.GObject):
gobject.TYPE_NONE, ([])),
}
- def __init__(self, time, fps=20, easing=EASE_OUT_EXPO):
+ def __init__(self, duration, fps=20, easing=EASE_OUT_EXPO):
gobject.GObject.__init__(self)
self._animations = []
- self._time = time
+ self._duration = duration
self._interval = 1.0 / fps
self._easing = easing
self._timeout_sid = 0
+ self._start_time = None
def add(self, animation):
self._animations.append(animation)
@@ -58,13 +59,13 @@ class Animator(gobject.GObject):
self.emit('completed')
def _next_frame_cb(self):
- current_time = min(self._time, time.time() - self._start_time)
+ current_time = min(self._duration, time.time() - self._start_time)
current_time = max(current_time, 0.0)
for animation in self._animations:
- animation.do_frame(current_time, self._time, self._easing)
+ animation.do_frame(current_time, self._duration, self._easing)
- if current_time == self._time:
+ if current_time == self._duration:
self.stop()
return False
else:
@@ -75,18 +76,18 @@ class Animation(object):
self.start = start
self.end = end
- def do_frame(self, time, duration, easing):
+ def do_frame(self, t, duration, easing):
start = self.start
change = self.end - self.start
- if time == duration:
+ if t == duration:
# last frame
frame = self.end
else:
if easing == EASE_OUT_EXPO:
- frame = change * (-pow(2, -10 * time/duration) + 1) + start;
+ frame = change * (-pow(2, -10 * t / duration) + 1) + start
elif easing == EASE_IN_EXPO:
- frame = change * pow(2, 10 * (time / duration - 1)) + start;
+ frame = change * pow(2, 10 * (t / duration - 1)) + start
self.next_frame(frame)