Add layout manager and a circle layout
parent
a02313d85a
commit
fe69904b6c
@ -0,0 +1,21 @@
|
|||||||
|
import math
|
||||||
|
|
||||||
|
from sugar.scene.LayoutManager import LayoutManager
|
||||||
|
|
||||||
|
class CircleLayout(LayoutManager):
|
||||||
|
def __init__(self, radium):
|
||||||
|
LayoutManager.__init__(self)
|
||||||
|
|
||||||
|
self._radium = radium
|
||||||
|
|
||||||
|
def layout_group(self, group):
|
||||||
|
step = 2 * math.pi / len(group.get_actors())
|
||||||
|
angle = 2 * math.pi
|
||||||
|
for actor in group.get_actors():
|
||||||
|
self._update_position(actor, angle)
|
||||||
|
angle -= step
|
||||||
|
|
||||||
|
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))
|
@ -0,0 +1,7 @@
|
|||||||
|
class LayoutManager:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def layout_group(self, group):
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue