diff options
| author | Lex Neva <github@lexneva.name> | 2017-10-17 18:25:00 +0100 |
|---|---|---|
| committer | Lex Neva <github@lexneva.name> | 2017-10-17 18:25:00 +0100 |
| commit | 6bfe4eb0d2ff4c0c3db14c6e18c49d19fd30c3a3 (patch) | |
| tree | abd5d88796efb60caf380c54b39dafdbe11b5898 /embroider.py | |
| parent | eff59de06dc4e6cf03da0b803fef7928476247d5 (diff) | |
don't go the long way around the outline
Diffstat (limited to 'embroider.py')
| -rw-r--r-- | embroider.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/embroider.py b/embroider.py index 68abda5f..36dc5bcc 100644 --- a/embroider.py +++ b/embroider.py @@ -940,17 +940,28 @@ class AutoFill(Fill): def connect_points(self, patch, start, end): outline_index = self.which_outline(start) outline = self.shape.boundary[outline_index] + outline_length = outline.length start = outline.project(shgeo.Point(*start)) end = outline.project(shgeo.Point(*end)) + travel_distance = abs(end - start) direction = math.copysign(1.0, end - start) - while (end - start) * direction > 0: + print >> dbg, "connect_points:", start, end, outline_length, abs(end-start)>outline_length/2.0 + if abs(end-start) > outline_length/2.0: + print >> dbg, "connect_points: flipping" + direction = -direction + travel_distance = outline_length - travel_distance + + travelled = 0 + + while travelled < travel_distance: stitch = outline.interpolate(start) patch.add_stitch(PyEmb.Point(stitch.x, stitch.y)) start += self.running_stitch_length * direction + travelled += self.running_stitch_length stitch = outline.interpolate(end) end = PyEmb.Point(stitch.x, stitch.y) |
