kopia lustrzana https://github.com/inkstitch/inkstitch
				
				
				
			add clip option
							rodzic
							
								
									85d19c6f62
								
							
						
					
					
						commit
						c01fb85c3d
					
				|  | @ -553,6 +553,16 @@ class FillStitch(EmbroideryElement): | |||
|     def expand(self): | ||||
|         return self.get_float_param('expand_mm', 0) | ||||
| 
 | ||||
|     @property | ||||
|     @param('clip', _('Clip path'), | ||||
|            tooltip=_('Constrain stitching to the shape.  Useful when smoothing and expand are used.'), | ||||
|            type='boolean', | ||||
|            default=False, | ||||
|            select_items=[('fill_method', 'meander_fill')], | ||||
|            sort_index=6) | ||||
|     def clip(self): | ||||
|         return self.get_boolean_param('clip', False) | ||||
| 
 | ||||
|     @property | ||||
|     @param('underpath', | ||||
|            _('Underpath'), | ||||
|  | @ -648,7 +658,7 @@ class FillStitch(EmbroideryElement): | |||
|                         elif self.fill_method == 'guided_fill': | ||||
|                             stitch_groups.extend(self.do_guided_fill(fill_shape, previous_stitch_group, start, end)) | ||||
|                         elif self.fill_method == 'meander_fill': | ||||
|                             stitch_groups.extend(self.do_meander_fill(fill_shape, i, start, end)) | ||||
|                             stitch_groups.extend(self.do_meander_fill(fill_shape, shape, i, start, end)) | ||||
|                         elif self.fill_method == 'circular_fill': | ||||
|                             stitch_groups.extend(self.do_circular_fill(fill_shape, previous_stitch_group, start, end)) | ||||
|                 except ExitThread: | ||||
|  | @ -792,11 +802,11 @@ class FillStitch(EmbroideryElement): | |||
|             )) | ||||
|         return [stitch_group] | ||||
| 
 | ||||
|     def do_meander_fill(self, shape, i, starting_point, ending_point): | ||||
|     def do_meander_fill(self, shape, original_shape, i, starting_point, ending_point): | ||||
|         stitch_group = StitchGroup( | ||||
|             color=self.color, | ||||
|             tags=("meander_fill", "meander_fill_top"), | ||||
|             stitches=meander_fill(self, shape, i, starting_point, ending_point)) | ||||
|             stitches=meander_fill(self, shape, original_shape, i, starting_point, ending_point)) | ||||
|         return [stitch_group] | ||||
| 
 | ||||
|     @cache | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ from ..utils.threading import check_stop_flag | |||
| from .running_stitch import running_stitch | ||||
| 
 | ||||
| 
 | ||||
| def meander_fill(fill, shape, shape_index, starting_point, ending_point): | ||||
| def meander_fill(fill, shape, original_shape, shape_index, starting_point, ending_point): | ||||
|     debug.log(f"meander pattern: {fill.meander_pattern}") | ||||
|     tile = get_tile(fill.meander_pattern) | ||||
|     if not tile: | ||||
|  | @ -40,7 +40,7 @@ def meander_fill(fill, shape, shape_index, starting_point, ending_point): | |||
|     start, end = find_starting_and_ending_nodes(graph, shape, starting_point, ending_point) | ||||
|     rng = iter_uniform_floats(fill.random_seed, 'meander-fill', shape_index) | ||||
| 
 | ||||
|     return post_process(generate_meander_path(graph, start, end, rng), shape, fill) | ||||
|     return post_process(generate_meander_path(graph, start, end, rng), shape, original_shape, fill) | ||||
| 
 | ||||
| 
 | ||||
| def get_tile(tile_id): | ||||
|  | @ -175,14 +175,16 @@ def replace_edge_pair(path, edge1, edge2, graph, graph_nodes): | |||
| 
 | ||||
| 
 | ||||
| @debug.time | ||||
| def post_process(points, shape, fill): | ||||
| def post_process(points, shape, original_shape, fill): | ||||
|     debug.log(f"smoothness: {fill.smoothness}") | ||||
|     # debug.log_line_string(LineString(points), "pre-smoothed", "#FF0000") | ||||
|     smoothed_points = smooth_path(points, fill.smoothness) | ||||
|     smoothed_points = [InkStitchPoint.from_tuple(point) for point in smoothed_points] | ||||
| 
 | ||||
|     stitches = running_stitch(smoothed_points, fill.running_stitch_length, fill.running_stitch_tolerance) | ||||
|     stitches = clamp_path_to_polygon(stitches, shape) | ||||
| 
 | ||||
|     if fill.clip: | ||||
|         stitches = clamp_path_to_polygon(stitches, original_shape) | ||||
| 
 | ||||
|     return stitches | ||||
| 
 | ||||
|  |  | |||
|  | @ -97,6 +97,7 @@ inkstitch_attribs = [ | |||
|     'underpath', | ||||
|     'flip', | ||||
|     'expand_mm', | ||||
|     'clip', | ||||
|     # stroke | ||||
|     'stroke_method', | ||||
|     'bean_stitch_repeats', | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Lex Neva
						Lex Neva