summaryrefslogtreecommitdiff
path: root/lib/elements/satin_column.py
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2023-07-08 20:48:14 -0400
committerLex Neva <github.com@lexneva.name>2023-07-08 20:48:14 -0400
commit661ae39546497bd2e4eb48496903405cfe919a18 (patch)
treef03812935cb9a0cfdbc28d49d16ec30e058322c4 /lib/elements/satin_column.py
parent71e09496c27e1742ce4d7eaa3d4333f1a20f252e (diff)
produce only one satin from convert to satin
Diffstat (limited to 'lib/elements/satin_column.py')
-rw-r--r--lib/elements/satin_column.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py
index 86c6d05a..cc0cda9f 100644
--- a/lib/elements/satin_column.py
+++ b/lib/elements/satin_column.py
@@ -825,6 +825,38 @@ class SatinColumn(EmbroideryElement):
return SatinColumn(node)
+ def merge(self, satin):
+ """Merge this satin with another satin
+
+ This method expects that the provided satin continues on directly after
+ this one, as would be the case, for example, if the two satins were the
+ result of the split() method.
+
+ Returns a new SatinColumn instance that combines the rails and rungs of
+ this satin and the provided satin. A rung is added at the end of this
+ satin.
+ """
+ rails = [self.flatten_subpath(rail) for rail in self.rails]
+ other_rails = [satin.flatten_subpath(rail) for rail in satin.rails]
+
+ if len(rails) != 2 or len(other_rails) != 2:
+ # weird non-satin things, give up and don't merge
+ return self
+
+ rails[0].extend(other_rails[0])
+ rails[1].extend(other_rails[1])
+
+ rungs = [self.flatten_subpath(rung) for rung in self.rungs]
+ other_rungs = [satin.flatten_subpath(rung) for rung in satin.rungs]
+
+ # add a rung at the end of my satin
+ rungs.append([rails[0][-1], rails[1][-1]])
+
+ # add on the other satin's rungs
+ rungs.extend(other_rungs)
+
+ return self._csp_to_satin(point_lists_to_csp(rails + rungs))
+
@property
@cache
def center_line(self):