From 99efa5a7d5eeedc34ac3af79afc1bdcd4d26ba72 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 23 Jul 2022 12:01:46 -0400 Subject: s/patch/stitch_group/g --- lib/patterns.py | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'lib/patterns.py') diff --git a/lib/patterns.py b/lib/patterns.py index aca6155c..136b988f 100644 --- a/lib/patterns.py +++ b/lib/patterns.py @@ -10,50 +10,50 @@ from .stitch_plan import Stitch from .utils import Point -def apply_patterns(patches, node): +def apply_patterns(stitch_groups, node): patterns = get_marker_elements(node, "pattern") - _apply_fill_patterns(patterns['fill'], patches) - _apply_stroke_patterns(patterns['stroke'], patches) + _apply_fill_patterns(patterns['fill'], stitch_groups) + _apply_stroke_patterns(patterns['stroke'], stitch_groups) -def _apply_stroke_patterns(patterns, patches): +def _apply_stroke_patterns(patterns, stitch_groups): for pattern in patterns: - for patch in patches: - patch_points = [] - for i, stitch in enumerate(patch.stitches): - patch_points.append(stitch) - if i == len(patch.stitches) - 1: + for stitch_group in stitch_groups: + stitch_group_points = [] + for i, stitch in enumerate(stitch_group.stitches): + stitch_group_points.append(stitch) + if i == len(stitch_group.stitches) - 1: continue - intersection_points = _get_pattern_points(stitch, patch.stitches[i+1], pattern) + intersection_points = _get_pattern_points(stitch, stitch_group.stitches[i + 1], pattern) for point in intersection_points: - patch_points.append(Stitch(point, tags=('pattern_point',))) - patch.stitches = patch_points + stitch_group_points.append(Stitch(point, tags=('pattern_point',))) + stitch_group.stitches = stitch_group_points -def _apply_fill_patterns(patterns, patches): +def _apply_fill_patterns(patterns, stitch_groups): for pattern in patterns: - for patch in patches: - patch_points = [] - for i, stitch in enumerate(patch.stitches): + for stitch_group in stitch_groups: + stitch_group_points = [] + for i, stitch in enumerate(stitch_group.stitches): if not shgeo.Point(stitch).within(pattern): # keep points outside the fill pattern - patch_points.append(stitch) - elif i - 1 < 0 or i >= len(patch.stitches) - 1: + stitch_group_points.append(stitch) + elif i - 1 < 0 or i >= len(stitch_group.stitches) - 1: # keep start and end points - patch_points.append(stitch) + stitch_group_points.append(stitch) elif stitch.has_tag('fill_row_start') or stitch.has_tag('fill_row_end'): # keep points if they are the start or end of a fill stitch row - patch_points.append(stitch) + stitch_group_points.append(stitch) elif stitch.has_tag('auto_fill') and not stitch.has_tag('auto_fill_top'): # keep auto-fill underlay - patch_points.append(stitch) + stitch_group_points.append(stitch) elif stitch.has_tag('auto_fill_travel'): # keep travel stitches (underpath or travel around the border) - patch_points.append(stitch) + stitch_group_points.append(stitch) elif stitch.has_tag('satin_column') and not stitch.has_tag('satin_split_stitch'): # keep satin column stitches unless they are split stitches - patch_points.append(stitch) - patch.stitches = patch_points + stitch_group_points.append(stitch) + stitch_group.stitches = stitch_group_points def _get_pattern_points(first, second, pattern): -- cgit v1.2.3