kopia lustrzana https://github.com/inkstitch/inkstitch
switch to millimeters and make pixels_per_millimeter an option
rodzic
b63abea797
commit
14ec80d012
|
@ -4,6 +4,7 @@
|
|||
<id>jonh.embroider</id>
|
||||
<dependency type="executable" location="extensions">embroider.py</dependency>
|
||||
<dependency type="executable" location="extensions">inkex.py</dependency>
|
||||
<param name="pixels_per_mm" type="float" min="1" max="100" precision="2" _gui-text="How many pixels on-screen equal one millimeter in embroidery output">10</param>
|
||||
<param name="zigzag_spacing_mm" type="float" min="0.01" max="5.00" precision="2" _gui-text="Zigzag spacing (mm)">1.00</param>
|
||||
<param name="row_spacing_mm" type="float" min="0.01" max="5.00" precision="2" _gui-text="Row spacing (mm)">0.40</param>
|
||||
<param name="max_stitch_len_mm" type="float" min="0.1" max="100.0" _gui-text="Maximum stitch length (mm)">3.0</param>
|
||||
|
|
40
embroider.py
40
embroider.py
|
@ -41,10 +41,6 @@ from pprint import pformat
|
|||
|
||||
dbg = open("/tmp/embroider-debug.txt", "w")
|
||||
PyEmb.dbg = dbg
|
||||
#pixels_per_millimeter = 90.0 / 25.4
|
||||
|
||||
#this makes each pixel worth one tenth of a millimeter
|
||||
pixels_per_millimeter = 10
|
||||
|
||||
# a 0.5pt stroke becomes a straight line.
|
||||
STROKE_MIN = 0.5
|
||||
|
@ -281,14 +277,18 @@ class Embroider(inkex.Effect):
|
|||
action="store", type="int",
|
||||
dest="max_backups", default=5,
|
||||
help="Max number of backups of output files to keep.")
|
||||
self.OptionParser.add_option("-p", "--pixels_per_mm",
|
||||
action="store", type="int",
|
||||
dest="pixels_per_millimeter", default=10,
|
||||
help="Number of on-screen pixels per millimeter.")
|
||||
self.patches = []
|
||||
|
||||
def process_one_path(self, node, shpath, threadcolor, angle):
|
||||
#self.add_shapely_geo_to_svg(shpath.boundary, color="#c0c000")
|
||||
|
||||
flip = get_boolean_param(node, "flip", False)
|
||||
row_spacing_px = get_float_param(node, "row_spacing", self.row_spacing_px)
|
||||
max_stitch_len_px = get_float_param(node, "max_stitch_length", self.max_stitch_len_px)
|
||||
row_spacing_px = get_float_param(node, "row_spacing", self.options.row_spacing_mm) * self.options.pixels_per_millimeter
|
||||
max_stitch_len_px = get_float_param(node, "max_stitch_length", self.options.max_stitch_len_mm) * self.options.pixels_per_millimeter
|
||||
num_staggers = get_int_param(node, "staggers", 4)
|
||||
|
||||
rows_of_segments = self.intersect_region_with_grating(shpath, row_spacing_px, angle, flip)
|
||||
|
@ -340,7 +340,7 @@ class Embroider(inkex.Effect):
|
|||
|
||||
# only stitch the first point if it's a reasonable distance away from the
|
||||
# last stitch
|
||||
if last_end is None or (beg - last_end).length() > 0.5 * pixels_per_millimeter:
|
||||
if last_end is None or (beg - last_end).length() > 0.5 * self.options.pixels_per_millimeter:
|
||||
patch.addStitch(beg)
|
||||
|
||||
# Now, imagine the coordinate axes rotated by 'angle' degrees, such that
|
||||
|
@ -366,7 +366,7 @@ class Embroider(inkex.Effect):
|
|||
patch.addStitch(beg + offset * row_direction)
|
||||
offset += max_stitch_len_px
|
||||
|
||||
if (end - patch.stitches[-1]).length() > 0.1 * pixels_per_millimeter:
|
||||
if (end - patch.stitches[-1]).length() > 0.1 * self.options.pixels_per_millimeter:
|
||||
patch.addStitch(end)
|
||||
|
||||
last_end = end
|
||||
|
@ -582,11 +582,11 @@ class Embroider(inkex.Effect):
|
|||
old_stdout = sys.stdout
|
||||
sys.stdout = sys.stderr
|
||||
|
||||
self.row_spacing_px = self.options.row_spacing_mm * pixels_per_millimeter
|
||||
self.zigzag_spacing_px = self.options.zigzag_spacing_mm * pixels_per_millimeter
|
||||
self.max_stitch_len_px = self.options.max_stitch_len_mm*pixels_per_millimeter
|
||||
self.running_stitch_len_px = self.options.running_stitch_len_mm*pixels_per_millimeter
|
||||
self.collapse_len_px = self.options.collapse_len_mm*pixels_per_millimeter
|
||||
self.row_spacing_px = self.options.row_spacing_mm * self.options.pixels_per_millimeter
|
||||
self.zigzag_spacing_px = self.options.zigzag_spacing_mm * self.options.pixels_per_millimeter
|
||||
self.max_stitch_len_px = self.options.max_stitch_len_mm * self.options.pixels_per_millimeter
|
||||
self.running_stitch_len_px = self.options.running_stitch_len_mm * self.optoins.pixels_per_millimeter
|
||||
self.collapse_len_px = self.options.collapse_len_mm * self.options.pixels_per_millimeter
|
||||
|
||||
self.svgpath = inkex.addNS('path', 'svg')
|
||||
self.svgdefs = inkex.addNS('defs', 'svg')
|
||||
|
@ -646,8 +646,8 @@ class Embroider(inkex.Effect):
|
|||
#dbg.write("stroke_width is <%s>\n" % repr(stroke_width))
|
||||
#dbg.flush()
|
||||
|
||||
running_stitch_len_px = get_float_param(node, "stitch_length", self.running_stitch_len_px)
|
||||
zigzag_spacing_px = get_float_param(node, "zigzag_spacing", self.zigzag_spacing_px)
|
||||
running_stitch_len_px = get_float_param(node, "stitch_length", self.options.running_stitch_len_mm) * self.pixels_per_millimeter
|
||||
zigzag_spacing_px = get_float_param(node, "zigzag_spacing", self.options.zigzag_spacing_mm) * self.options.pixels_per_millimeter
|
||||
repeats = get_int_param(node, "repeats", 1)
|
||||
|
||||
paths = flatten(parse_path(node), self.options.flat)
|
||||
|
@ -761,13 +761,13 @@ class Embroider(inkex.Effect):
|
|||
self.validate_satin_column(node, csp)
|
||||
|
||||
# fetch parameters
|
||||
zigzag_spacing_px = get_float_param(node, "zigzag_spacing", self.zigzag_spacing_px)
|
||||
pull_compensation_px = get_float_param(node, "pull_compensation", 0)
|
||||
underlay_inset = get_float_param(node, "satin_underlay_inset", 0)
|
||||
underlay_stitch_len_px = get_float_param(node, "stitch_length", self.running_stitch_len_px)
|
||||
zigzag_spacing_px = get_float_param(node, "zigzag_spacing", self.zigzag_spacing_mm) * self.options.pixels_per_millimeter
|
||||
pull_compensation_px = get_float_param(node, "pull_compensation", 0) * self.options.pixels_per_millimeter
|
||||
underlay_inset = get_float_param(node, "satin_underlay_inset", 0) * self.options.pixels_per_millimeter
|
||||
underlay_stitch_len_px = get_float_param(node, "stitch_length", self.running_stitch_len_mm) * self.options.pixels_per_millimeter
|
||||
underlay = get_boolean_param(node, "satin_underlay", False)
|
||||
center_walk = get_boolean_param(node, "satin_center_walk", False)
|
||||
zigzag_underlay_spacing = get_float_param(node, "satin_zigzag_underlay_spacing", 0)
|
||||
zigzag_underlay_spacing = get_float_param(node, "satin_zigzag_underlay_spacing", 0) * self.options.pixels_per_millimeter
|
||||
zigzag_underlay_inset = underlay_inset / 2.0
|
||||
|
||||
# A path is a collection of tuples, each of the form:
|
||||
|
|
|
@ -4,20 +4,20 @@
|
|||
<id>jonh.embroider.params</id>
|
||||
<dependency type="executable" location="extensions">embroider_params.py</dependency>
|
||||
<dependency type="executable" location="extensions">inkex.py</dependency>
|
||||
<param name="zigzag_spacing" type="string" _gui-text="Zigzag spacing (pixels)"></param>
|
||||
<param name="stitch_length" type="string" _gui-text="Running stitch length (pixels)"></param>
|
||||
<param name="row_spacing" type="string" _gui-text="Row spacing (pixels)"></param>
|
||||
<param name="max_stitch_length" type="string" _gui-text="Maximum stitch length (pixels)"></param>
|
||||
<param name="zigzag_spacing" type="string" _gui-text="Zigzag spacing (mm)"></param>
|
||||
<param name="stitch_length" type="string" _gui-text="Running stitch length (mm)"></param>
|
||||
<param name="row_spacing" type="string" _gui-text="Row spacing (mm)"></param>
|
||||
<param name="max_stitch_length" type="string" _gui-text="Maximum stitch length (mm)"></param>
|
||||
<param name="repeats" type="string" _gui-text="Repeats (stroke only)"></param>
|
||||
<param name="angle" type="string" _gui-text="Angle for lines in fills"></param>
|
||||
<param name="pull_compensation" type="string" _gui-text="Pull compensation for satin column (pixels)"></param>
|
||||
<param name="pull_compensation" type="string" _gui-text="Pull compensation for satin column (mm)"></param>
|
||||
<param name="hatching" type="string" _gui-text="Hatching? (yes/no)"></param>
|
||||
<param name="flip" type="string" _gui-text="Flip fill? (yes/no)"></param>
|
||||
<param name="satin_column" type="string" _gui-text="Satin Column? (yes/no)"></param>
|
||||
<param name="satin_underlay" type="string" _gui-text="Edge-walk underlay for satin Column? (yes/no)"></param>
|
||||
<param name="satin_underlay_inset" type="string" _gui-text="Inset for satin colum underlay (pixels)"></param>
|
||||
<param name="satin_underlay_inset" type="string" _gui-text="Inset for satin colum underlay (mm)"></param>
|
||||
<param name="satin_center_walk" type="string" _gui-text="Satin center walk underlay? (yes/no)"></param>
|
||||
<param name="satin_zigzag_underlay_spacing" type="string" _gui-text="Zigzag underlay spacing (pixels)"></param>
|
||||
<param name="satin_zigzag_underlay_spacing" type="string" _gui-text="Zigzag underlay spacing (mm)"></param>
|
||||
<param name="stroke_first" type="string" _gui-text="Stitch stroke before fill? (yes/no)"></param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
|
|
Ładowanie…
Reference in New Issue