sugar-toolkit-gtk3/sugar/scene/CircleLayout.py

26 lines
634 B
Python
Raw Normal View History

2006-07-22 12:28:59 +02:00
import math
from sugar.scene.LayoutManager import LayoutManager
class CircleLayout(LayoutManager):
def __init__(self, radium):
LayoutManager.__init__(self)
self._radium = radium
2006-07-22 13:48:47 +02:00
self._angle = 0
def set_angle(self, angle):
self._angle = angle
2006-07-22 12:28:59 +02:00
def layout_group(self, group):
step = 2 * math.pi / len(group.get_actors())
2006-07-22 13:48:47 +02:00
angle = self._angle
2006-07-22 12:28:59 +02:00
for actor in group.get_actors():
self._update_position(actor, angle)
2006-07-22 13:48:47 +02:00
angle += step
2006-07-22 12:28:59 +02:00
def _update_position(self, actor, angle):
x = math.cos(angle) * self._radium + self._radium
y = math.sin(angle) * self._radium + self._radium
actor.set_position(int(x), int(y))