33# Copyright (c) 2025 Authors
44# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
55
6+ from math import sqrt
7+
68from inkex import Boolean , Path , PathElement
79from shapely import minimum_bounding_circle , union_all
810from shapely .geometry import LineString , Polygon
@@ -20,6 +22,7 @@ class KnockdownFill(InkstitchExtension):
2022 def __init__ (self , * args , ** kwargs ):
2123 InkstitchExtension .__init__ (self , * args , ** kwargs )
2224 self .arg_parser .add_argument ("--notebook" )
25+ self .arg_parser .add_argument ("-l" , "--stitch-length" , type = float , default = 3 , dest = "stitch_length" )
2326 self .arg_parser .add_argument ("-k" , "--keep-holes" , type = Boolean , default = True , dest = "keep_holes" )
2427 self .arg_parser .add_argument ("-o" , "--offset" , type = float , default = 0 , dest = "offset" )
2528 self .arg_parser .add_argument ("-j" , "--join-style" , type = str , default = "1" , dest = "join_style" )
@@ -137,15 +140,19 @@ def _get_hole_paths(self, polygon):
137140 return d
138141
139142 def insert_path (self , d , transform , parent , index ):
143+ stitch_length = self .options .stitch_length
144+ row_spacing = (sqrt (3 ) * stitch_length ) / 2
145+
140146 path = PathElement ()
141147 path .set ('d' , d )
142148 path .label = self .svg .get_unique_id ('Knockdown ' )
143149 path .set ('transform' , transform )
144150
145- path .set ('inkstitch:row_spacing_mm' , '2.6' )
151+ path .set ('inkstitch:max_stitch_length_mm' , stitch_length )
152+ path .set ('inkstitch:row_spacing_mm' , '{0:.4f}' .format (row_spacing ))
146153 path .set ('inkstitch:fill_underlay_angle' , '60 -60' )
147- path .set ('inkstitch:fill_underlay_max_stitch_length_mm' , '3' )
148- path .set ('inkstitch:fill_underlay_row_spacing_mm' , '2.6' )
154+ path .set ('inkstitch:fill_underlay_max_stitch_length_mm' , stitch_length )
155+ path .set ('inkstitch:fill_underlay_row_spacing_mm' , '{0:.4f}' . format ( row_spacing ) )
149156 path .set ('inkstitch:underlay_underpath' , 'False' )
150157 path .set ('inkstitch:underpath' , 'False' )
151158 path .set ('inkstitch:staggers' , '2' )
0 commit comments