Line 29: |
Line 29: |
| * [[User:Walter/sandbox]] | | * [[User:Walter/sandbox]] |
| * [[User:Walter/favoritelayout.py]] | | * [[User:Walter/favoritelayout.py]] |
− | [[Image:Spiral.png|thumb|left|<pre> | + | [[Image:Spiral.png|thumb|left|Spiral Home View]] |
− | def _calculate_position(self, radius, icon_size, index, children_count):
| + | [[Image:FermatSpiral.png|thumb|left|Fermat Spiral]] |
− | width, height = self.box.get_allocation()
| |
− | # angle decreases as the radius increases
| |
− | inc = 12.0 + index / 6.0
| |
− | angle = index * (2 * math.pi / inc) - math.pi / 2
| |
− | # radius is proportional to index/children_count
| |
− | 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
| |
− | return x, y
| |
− | </pre>]]
| |
− | [[Image:FermatSpiral.png|thumb|left|<pre> | |
− | def _calculate_position(self, radius, icon_size, index, children_count):
| |
− | width, height = self.box.get_allocation()
| |
− | # include an offset (8) to the index
| |
− | # so that the center of the spiral is left blank
| |
− | # angle = n * 137.5 degree or 2.4 radians
| |
− | angle = (index + 8) * 2.4
| |
− | | |
− | # radius = constant * sqrt(n)
| |
− | radius = (_MINIMUM_RADIUS / 5) * math.sqrt(index + 8)
| |
− | | |
− | x = radius * math.cos(angle) + (width - icon_size) / 2
| |
− | y = radius * math.sin(angle) + (height - icon_size -
| |
− | style.GRID_CELL_SIZE) / 2
| |
− | | |
− | return x, y
| |
− | </pre>]]
| |