summaryrefslogtreecommitdiff
path: root/lib/elements/satin_column.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2023-04-27 19:49:54 +0200
committerGitHub <noreply@github.com>2023-04-27 19:49:54 +0200
commit99aa6cc0092b25bc89411845cc59969df5249b19 (patch)
tree2050e089449aba99b052708bdf4e42738e62c30d /lib/elements/satin_column.py
parentc00084e3a22920878879af5efbaad9b1f7cf66a4 (diff)
Ensure synthesized rungs intersect (#2239)
Diffstat (limited to 'lib/elements/satin_column.py')
-rw-r--r--lib/elements/satin_column.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py
index 3a0b0f8e..4f083b21 100644
--- a/lib/elements/satin_column.py
+++ b/lib/elements/satin_column.py
@@ -454,15 +454,19 @@ class SatinColumn(EmbroideryElement):
# Don't bother putting rungs at the start and end.
points = points[1:-1]
else:
- # But do include one at the start if we wouldn't add one otherwise.
+ # But do include one near the start if we wouldn't add one otherwise.
# This avoids confusing other parts of the code.
- points = points[:-1]
+ linestring_rail = shgeo.LineString(points)
+ points = [linestring_rail.interpolate(0.2)]
rung_endpoints.append(points)
rungs = []
for start, end in zip(*rung_endpoints):
- rungs.append([[start, start, start], [end, end, end]])
+ rung = shgeo.LineString((start, end))
+ # make it a bit bigger so that it definitely intersects
+ rung = shaffinity.scale(rung, 1.1, 1.1).coords
+ rungs.append([[rung[0]] * 3, [rung[1]] * 3])
return rungs
@@ -613,8 +617,8 @@ class SatinColumn(EmbroideryElement):
rails.reverse()
path_list = rails
- rung_start = path_list[0].interpolate(0.1)
- rung_end = path_list[1].interpolate(0.1)
+ rung_start = path_list[0].interpolate(0.2)
+ rung_end = path_list[1].interpolate(0.2)
rung = shgeo.LineString((rung_start, rung_end))
# make it a bit bigger so that it definitely intersects
rung = shaffinity.scale(rung, 1.1, 1.1)
@@ -733,10 +737,14 @@ class SatinColumn(EmbroideryElement):
for path_list in path_lists:
if len(path_list) in (2, 4):
- # Add the rung at the start of the satin.
- rung_start = path_list[0].coords[0]
- rung_end = path_list[1].coords[0]
+ # Add the rung just after the start of the satin.
+ rung_start = path_list[0].interpolate(0.3)
+ rung_end = path_list[1].interpolate(0.3)
rung = shgeo.LineString((rung_start, rung_end))
+
+ # make it a bit bigger so that it definitely intersects
+ rung = shaffinity.scale(rung, 1.1, 1.1)
+
path_list.append(rung)
def _path_list_to_satins(self, path_list):