Small improvements

This commit is contained in:
Marco Pesenti Gritti 2006-07-22 14:32:04 +02:00
parent 1e3af85c40
commit 1c35f8d92c
2 changed files with 7 additions and 7 deletions

View File

@ -15,7 +15,7 @@ def __drawing_area_expose_cb(widget, event, stage):
stage.render(widget.window) stage.render(widget.window)
def __next_frame_cb(timeline, frame_num, group): def __next_frame_cb(timeline, frame_num, group):
angle = math.pi * 2 / timeline.get_n_frames() * frame_num angle = math.pi * 2 * frame_num / timeline.get_n_frames()
group.get_layout().set_angle(angle) group.get_layout().set_angle(angle)
group.do_layout() group.do_layout()
@ -55,7 +55,7 @@ drawing_area.show()
window.show() window.show()
timeline = Timeline(stage, 100) timeline = Timeline(stage, 300)
timeline.connect('next-frame', __next_frame_cb, icons_group) timeline.connect('next-frame', __next_frame_cb, icons_group)
timeline.connect('completed', __completed_cb, icons_group) timeline.connect('completed', __completed_cb, icons_group)
timeline.start() timeline.start()

View File

@ -3,10 +3,10 @@ import math
from sugar.scene.LayoutManager import LayoutManager from sugar.scene.LayoutManager import LayoutManager
class CircleLayout(LayoutManager): class CircleLayout(LayoutManager):
def __init__(self, radium): def __init__(self, radius):
LayoutManager.__init__(self) LayoutManager.__init__(self)
self._radium = radium self._radius = radius
self._angle = 0 self._angle = 0
def set_angle(self, angle): def set_angle(self, angle):
@ -20,6 +20,6 @@ class CircleLayout(LayoutManager):
angle += step angle += step
def _update_position(self, actor, angle): def _update_position(self, actor, angle):
x = math.cos(angle) * self._radium + self._radium x = math.cos(angle) * self._radius + self._radius
y = math.sin(angle) * self._radium + self._radium y = math.sin(angle) * self._radius + self._radius
actor.set_position(int(x), int(y)) actor.set_position(int(x + 0.5), int(y + 0.5))