summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2019-03-08 20:51:23 -0500
committerLex Neva <github.com@lexneva.name>2019-03-08 20:51:58 -0500
commit13b6c67644acaeff04918e8489e943b4a8795863 (patch)
treec2f0ae293799c4c50e1d8bfffd52f9f6bd69e2f6 /lib
parentd1c001857d1e389950b3f346c1a0413d82899ca4 (diff)
less haphazard positioning for commands
Diffstat (limited to 'lib')
-rw-r--r--lib/commands.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/commands.py b/lib/commands.py
index 53b9e77f..8e35d7ee 100644
--- a/lib/commands.py
+++ b/lib/commands.py
@@ -5,6 +5,7 @@ import sys
import cubicsuperpath
import inkex
+from shapely import geometry as shgeo
import simpletransform
from .i18n import _, N_
@@ -325,10 +326,15 @@ def get_command_pos(element, index, total):
# get a line running 30 pixels out from the shape
outline = element.shape.buffer(30).exterior
- # pick this item's spot arond the outline and perturb it a bit to avoid
- # stacking up commands if they run the extension multiple times
+ # find the top center point on the outline and start there
+ top_center = shgeo.Point(outline.centroid.x, outline.bounds[1])
+ start_position = outline.project(top_center, normalized=True)
+
+ # pick this item's spot around the outline and perturb it a bit to avoid
+ # stacking up commands if they add commands multiple times
position = index / float(total)
- position += random() * 0.1
+ position += random() * 0.05
+ position += start_position
return outline.interpolate(position, normalized=True)