From abb97e305ac9131a05c88629b4aed27490d46190 Mon Sep 17 00:00:00 2001 From: tatarize Date: Fri, 18 Sep 2020 12:26:20 -0700 Subject: [PATCH 1/2] add_pattern() given transformations. dx, dy for transform. sx, sy for scale. rotate for rotate. --- pyembroidery/EmbPattern.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pyembroidery/EmbPattern.py b/pyembroidery/EmbPattern.py index 3e0d866f..aa3b028e 100644 --- a/pyembroidery/EmbPattern.py +++ b/pyembroidery/EmbPattern.py @@ -580,7 +580,7 @@ def add_stitchblock(self, stitchblock): except AttributeError: self.add_stitch_absolute(stitch[2], stitch[0], stitch[1]) - def add_pattern(self, pattern): + def add_pattern(self, pattern, dx=None, dy=None, sx=None, sy=None, rotate=None): """ add_pattern merges the given pattern with the current pattern. It accounts for some edge conditions but not all of them. @@ -592,9 +592,24 @@ def add_pattern(self, pattern): :param pattern: pattern to add to current pattern :return: """ + if isinstance(pattern, str): + pattern = EmbPattern(pattern) if self.stitches[-1][2] == END: self.stitches = self.stitches[:-1] # Remove END, if exists - + if dx is not None or dy is not None: + if dx is None: + dx = 0 + if dy is None: + dy = 0 + self.add_command(MATRIX_TRANSLATE, dx, dy) + if sx is not None or sx is not None: + if sx is None: + sx = sy + if sy is None: + sy = sx + self.add_command(MATRIX_SCALE, sx, sy) + if rotate is not None: + self.add_command(MATRIX_ROTATE, rotate) # Add the new thread only if it's different from the last one self.fix_color_count() From 4db6b422f715f4e40b99bca905cb3d9b4cb83c25 Mon Sep 17 00:00:00 2001 From: tatarize Date: Fri, 18 Sep 2020 12:28:14 -0700 Subject: [PATCH 2/2] Version Bump to 1.4.21 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9539d393..b09b8734 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="pyembroidery", - version="1.4.20", + version="1.4.21", author="Tatarize", author_email="tatarize@gmail.com", description="Embroidery IO library",