Skip to content

Commit

Permalink
Merge pull request #103 from EmbroidePy/tatarize-add_pattern
Browse files Browse the repository at this point in the history
add_pattern() given transformations.
  • Loading branch information
tatarize authored Sep 18, 2020
2 parents ccc05f0 + 4db6b42 commit a5221f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions pyembroidery/EmbPattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pyembroidery",
version="1.4.20",
version="1.4.21",
author="Tatarize",
author_email="[email protected]",
description="Embroidery IO library",
Expand Down

0 comments on commit a5221f3

Please sign in to comment.