From 13b6c67644acaeff04918e8489e943b4a8795863 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 8 Mar 2019 20:51:23 -0500 Subject: [PATCH] less haphazard positioning for commands --- lib/commands.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/commands.py b/lib/commands.py index 53b9e77f2..8e35d7ee0 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)