diff options
| author | Lex Neva <github.com@lexneva.name> | 2023-07-15 11:25:38 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2023-07-15 11:25:48 -0400 |
| commit | de863d72eff6a6bd7326edc6b7293560e0fd5d35 (patch) | |
| tree | 46c3a5bad36ef968b17373e1ab1224f3229b097e /lib | |
| parent | b01870890b07c8e9ac4c843fac9461c7086f31f7 (diff) | |
more transform fixes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/elements/satin_column.py | 13 | ||||
| -rw-r--r-- | lib/extensions/convert_to_satin.py | 12 |
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index 8975a4ba..4ea26575 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -698,7 +698,7 @@ class SatinColumn(EmbroideryElement): new SatinColumn's node will not be in the SVG document. """ - return self._csp_to_satin(self.csp, True) + return self._csp_to_satin(self.csp) def split(self, split_point): """Split a satin into two satins at the specified point @@ -713,6 +713,9 @@ class SatinColumn(EmbroideryElement): Returns two new SatinColumn instances: the part before and the part after the split point. All parameters are copied over to the new SatinColumn instances. + + The returned SatinColumns will not be in the SVG document and will have + their transforms applied. """ cut_points = self._find_cut_points(split_point) @@ -814,12 +817,13 @@ class SatinColumn(EmbroideryElement): def _path_list_to_satins(self, path_list): return self._csp_to_satin(line_strings_to_csp(path_list)) - def _csp_to_satin(self, csp, remove_transform=False): + def _csp_to_satin(self, csp): node = deepcopy(self.node) d = paths.CubicSuperPath(csp).to_path() node.set("d", d) - if remove_transform and node.get("transform"): + # we've already applied the transform, so get rid of it + if node.get("transform"): del node.attrib["transform"] return SatinColumn(node) @@ -834,6 +838,9 @@ class SatinColumn(EmbroideryElement): 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. + + The returned SatinColumn will not be in the SVG document and will have + its transforms applied. """ rails = [self.flatten_subpath(rail) for rail in self.rails] other_rails = [satin.flatten_subpath(rail) for rail in satin.rails] diff --git a/lib/extensions/convert_to_satin.py b/lib/extensions/convert_to_satin.py index c579e9b4..4bb3588e 100644 --- a/lib/extensions/convert_to_satin.py +++ b/lib/extensions/convert_to_satin.py @@ -57,21 +57,22 @@ class ConvertToSatin(InkstitchExtension): # ignore paths with just one point -- they're not visible to the user anyway continue - satins = list(self.convert_path_to_satins(path, element.stroke_width, style_args, correction_transform, path_style)) + satins = list(self.convert_path_to_satins(path, element.stroke_width, style_args, path_style)) if satins: joined_satin = satins[0] for satin in satins[1:]: joined_satin = joined_satin.merge(satin) + joined_satin.node.set('transform', correction_transform) parent.insert(index, joined_satin.node) parent.remove(element.node) - def convert_path_to_satins(self, path, stroke_width, style_args, correction_transform, path_style, depth=0): + def convert_path_to_satins(self, path, stroke_width, style_args, path_style, depth=0): try: rails, rungs = self.path_to_satin(path, stroke_width, style_args) - yield SatinColumn(self.satin_to_svg_node(rails, rungs, correction_transform, path_style)) + yield SatinColumn(self.satin_to_svg_node(rails, rungs, path_style)) except SelfIntersectionError: # The path intersects itself. Split it in two and try doing the halves # individually. @@ -84,7 +85,7 @@ class ConvertToSatin(InkstitchExtension): halves = self.split_path(path) for path in halves: - for satin in self.convert_path_to_satins(path, stroke_width, style_args, correction_transform, path_style, depth=depth + 1): + for satin in self.convert_path_to_satins(path, stroke_width, style_args, path_style, depth=depth + 1): yield satin def split_path(self, path): @@ -332,7 +333,7 @@ class ConvertToSatin(InkstitchExtension): color = element.get_style('stroke', '#000000') return "stroke:%s;stroke-width:1px;fill:none" % (color) - def satin_to_svg_node(self, rails, rungs, correction_transform, path_style): + def satin_to_svg_node(self, rails, rungs, path_style): d = "" for path in chain(rails, rungs): d += "M" @@ -343,7 +344,6 @@ class ConvertToSatin(InkstitchExtension): return inkex.PathElement(attrib={ "id": self.uniqueId("path"), "style": path_style, - "transform": correction_transform, "d": d, INKSTITCH_ATTRIBS['satin_column']: "true", }) |
