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() 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",