Open main menu
Home
Random
Log in
Settings
About Sugar Labs
Disclaimers
Sugar Labs
Search
Changes
← Older edit
Newer edit →
User:Walter/favoriteslayout.py
(view source)
Revision as of 18:44, 9 September 2008
265 bytes added
,
18:44, 9 September 2008
no edit summary
Line 218:
Line 218:
def _calculate_position(self, radius, icon_size, index, children_count):
def _calculate_position(self, radius, icon_size, index, children_count):
width, height = self.box.get_allocation()
width, height = self.box.get_allocation()
−
+
# angle decreases as the radius increases
−
# go around 2 times, e
.
g
.
, 4 pi
+
inc = 12
.
0 + index / 6
.
0
−
angle = index * (
4
* math.pi /
children_count
) - math.pi / 2
+
angle = index * (
2
* math.pi /
inc
) - math.pi / 2
−
x =
radius
* math.cos(angle) + (width - icon_size) / 2
+
# radius is proportional to index/children_count
−
y =
radius
* math.sin(angle) + (height - icon_size -
+
myminimum = _MINIMUM_RADIUS * .667
+
newradius = ((radius - myminimum) * (index * 1.1) / children_count)
+
+ myminimum
+
x =
newradius
* math.cos(angle) + (width - icon_size) / 2
+
y =
newradius
* math.sin(angle) + (height - icon_size -
style.GRID_CELL_SIZE) / 2
style.GRID_CELL_SIZE) / 2
return x, y
return x, y
Walter
Bureaucrats
,
Administrators
10,505
edits