Skip to content

Commit a5221f3

Browse files
authored
Merge pull request #103 from EmbroidePy/tatarize-add_pattern
add_pattern() given transformations.
2 parents ccc05f0 + 4db6b42 commit a5221f3

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

pyembroidery/EmbPattern.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def add_stitchblock(self, stitchblock):
580580
except AttributeError:
581581
self.add_stitch_absolute(stitch[2], stitch[0], stitch[1])
582582

583-
def add_pattern(self, pattern):
583+
def add_pattern(self, pattern, dx=None, dy=None, sx=None, sy=None, rotate=None):
584584
"""
585585
add_pattern merges the given pattern with the current pattern. It accounts for some edge conditions but
586586
not all of them.
@@ -592,9 +592,24 @@ def add_pattern(self, pattern):
592592
:param pattern: pattern to add to current pattern
593593
:return:
594594
"""
595+
if isinstance(pattern, str):
596+
pattern = EmbPattern(pattern)
595597
if self.stitches[-1][2] == END:
596598
self.stitches = self.stitches[:-1] # Remove END, if exists
597-
599+
if dx is not None or dy is not None:
600+
if dx is None:
601+
dx = 0
602+
if dy is None:
603+
dy = 0
604+
self.add_command(MATRIX_TRANSLATE, dx, dy)
605+
if sx is not None or sx is not None:
606+
if sx is None:
607+
sx = sy
608+
if sy is None:
609+
sy = sx
610+
self.add_command(MATRIX_SCALE, sx, sy)
611+
if rotate is not None:
612+
self.add_command(MATRIX_ROTATE, rotate)
598613
# Add the new thread only if it's different from the last one
599614
self.fix_color_count()
600615

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="pyembroidery",
8-
version="1.4.20",
8+
version="1.4.21",
99
author="Tatarize",
1010
author_email="[email protected]",
1111
description="Embroidery IO library",

0 commit comments

Comments
 (0)