diff options
| author | Stefan Siegl <stesie@brokenpipe.de> | 2014-12-29 13:54:14 +0100 |
|---|---|---|
| committer | Stefan Siegl <stesie@brokenpipe.de> | 2014-12-29 13:54:14 +0100 |
| commit | e80f5f4003b9fa6dca8230fd60d0f52584ecf1b2 (patch) | |
| tree | 91472b45d35e4198322194efcb9a7f920003c200 | |
| parent | b9d08f87ce4fa504cedef732f26971335b058474 (diff) | |
Allow to hatch filled paths
| -rw-r--r-- | embroider.inx | 1 | ||||
| -rw-r--r-- | embroider.py | 20 |
2 files changed, 19 insertions, 2 deletions
diff --git a/embroider.inx b/embroider.inx index 15bc2484..da9a5d0e 100644 --- a/embroider.inx +++ b/embroider.inx @@ -7,6 +7,7 @@ <param name="row_spacing_mm" type="float" min="0.01" max="5.00" _gui-text="Row spacing (mm)">0.40</param> <param name="max_stitch_len_mm" type="float" min="0.1" max="10.0" _gui-text="Maximum stitch length (mm)">3.0</param> <param name="preserve_order" type="boolean" _gui-text="Preserve stacking order" description="if false, sorts by color, which saves thread changes. True preserves stacking order, important if you're laying colors over each other.">false</param> + <param name="hatch_filled_paths" type="boolean" _gui-text="Hatch filled paths" description="If false, filled paths are filled using equally-spaced lines. If true, filled paths are filled using hatching lines.">false</param> <param name="output_format" type="optiongroup" _gui-text="Output file format" appearance="minimal"> <_option value="melco">Melco</_option> <_option value="csv">Embroidermodder 2 CSV</_option> diff --git a/embroider.py b/embroider.py index a49491c3..435f3167 100644 --- a/embroider.py +++ b/embroider.py @@ -432,6 +432,11 @@ class Embroider(inkex.Effect): choices=["true","false"], dest="preserve_order", default="false", help="Sort by stacking order instead of color") + self.OptionParser.add_option("-H", "--hatch_filled_paths", + action="store", type="choice", + choices=["true","false"], + dest="hatch_filled_paths", default="false", + help="Use hatching lines instead of equally-spaced lines to fill paths") self.OptionParser.add_option("-O", "--output_format", action="store", type="choice", choices=["melco", "csv"], @@ -482,6 +487,8 @@ class Embroider(inkex.Effect): def intersect_region_with_grating(self, shpath): dbg.write("bounds = %s\n" % str(shpath.bounds)) bbox = shpath.bounds + hatching = self.options.hatch_filled_paths == "true" + dbg.write("hatching is %s\n" % hatching) delta = self.row_spacing_px/2.0 bbox_sz = (bbox[2]-bbox[0],bbox[3]-bbox[1]) @@ -498,13 +505,22 @@ class Embroider(inkex.Effect): p_inc = PyEmb.Point(0, self.row_spacing_px) count = (bbox[3]-bbox[1])/self.row_spacing_px + 2 + if hatching: + count *= 2 + rows = [] steps = 0 while (steps < count): try: steps += 1 - p0 += p_inc - p1 += p_inc + if hatching: + if steps % 2 == 1: + p1 += p_inc + else: + p0 += p_inc + else: + p0 += p_inc + p1 += p_inc endpoints = [p0.as_tuple(), p1.as_tuple()] shline = shgeo.LineString(endpoints) res = shline.intersection(shpath) |
