summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-07-10 20:03:51 -0400
committerLex Neva <github.com@lexneva.name>2018-07-12 20:13:46 -0400
commit0c6288f7693a6aeb2d3dd15ad727d868de183b6a (patch)
tree4598354fd297b9a5169ebb97389fee3c9a9e3ff7 /lib
parent73565ae691b409af9190a02485e51ed590510384 (diff)
perturb the positions of commands a bit
Diffstat (limited to 'lib')
-rw-r--r--lib/extensions/commands.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/extensions/commands.py b/lib/extensions/commands.py
index 4c9fd172..5767447c 100644
--- a/lib/extensions/commands.py
+++ b/lib/extensions/commands.py
@@ -4,6 +4,7 @@ import inkex
import simpletransform
import cubicsuperpath
from copy import deepcopy
+from random import random
from shapely import geometry as shgeo
from .base import InkstitchExtension
@@ -84,8 +85,16 @@ class Commands(InkstitchExtension):
def get_command_pos(self, element, index, total):
# Put command symbols 30 pixels out from the shape, spaced evenly around it.
+
+ # get a line running 30 pixels out from the shape
outline = element.shape.buffer(30).exterior
- return outline.interpolate(index / float(total), normalized=True)
+
+ # 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
+ position = index / float(total)
+ position += random() * 0.1
+
+ return outline.interpolate(position, normalized=True)
def remove_legacy_param(self, element, command):
if command == "trim" or command == "stop":