Split into classes for Fill, Stroke, and SatinColumn.  Renamed params to be
the same across XML attributes and OptionParser.  Added distinct stitch length
params for satin underlay.  Renamed "satin underlay" to "contour underlay" and
split out "center walk underlay" and "zigzag underlay".

The code is ten times more readable, parameters make more sense, and everything
is specified by the user in millimeters.  Basically, everything is way better.
pull/2/merge
Lex Neva 2016-10-30 22:58:51 -04:00
rodzic 9249a3ae77
commit 841e9196ba
6 zmienionych plików z 2052 dodań i 775 usunięć

Wyświetl plik

@ -60,6 +60,11 @@ class Point:
def __cmp__(self, other):
return cmp(self.as_tuple(), other.as_tuple())
def __getitem__(self, item):
return self.as_tuple()[item]
def __len__(self):
return 2
class Stitch(Point):

Wyświetl plik

@ -4,7 +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="pixels_per_mm" type="float" min="1" max="100" precision="2" _gui-text="Pixels per millimeter">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>

Plik diff jest za duży Load Diff

1147
embroider.py.save 100644

Plik diff jest za duży Load Diff

Wyświetl plik

@ -4,20 +4,23 @@
<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 (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="zigzag_spacing_mm" type="string" _gui-text="Zigzag spacing (mm)"></param>
<param name="running_stitch_length_mm" type="string" _gui-text="Running stitch length (mm)"></param>
<param name="row_spacing_mm" type="string" _gui-text="Row spacing (mm)"></param>
<param name="max_stitch_length_mm" type="string" _gui-text="Maximum stitch length for fills (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 (mm)"></param>
<param name="hatching" type="string" _gui-text="Hatching? (yes/no)"></param>
<param name="pull_compensation_mm" type="string" _gui-text="Pull compensation for satin column (mm)"></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 (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 (mm)"></param>
<param name="contour_underlay" type="string" _gui-text="Edge-walk underlay for satin Column? (yes/no)"></param>
<param name="contour_underlay_inset_mm" type="string" _gui-text="Inset for satin colum underlay (mm)"></param>
<param name="contour_underlay_stitch_length_mm" type="string" _gui-text="Stitch length (mm) for contour underlay (defaults to running stitch length)"></param>
<param name="center_walk_underlay" type="string" _gui-text="Satin center walk underlay? (yes/no)"></param>
<param name="center_walk_underlay_stitch_length_mm" type="string" _gui-text="Stitch length (mm) for center walk underlay (defaults to running stitch length)"></param>
<param name="zigzag_underlay" type="string" _gui-text="Zig-Zag underlay for satin Column? (yes/no)"></param>
<param name="zigzag_spacing_mm" type="string" _gui-text="Zigzag underlay spacing (mm)"></param>
<param name="zigzag_underlay_inset_mm" type="string" _gui-text="Inset for zigzag underlay (mm)"></param>
<param name="stroke_first" type="string" _gui-text="Stitch stroke before fill? (yes/no)"></param>
<effect>
<object-type>all</object-type>

Wyświetl plik

@ -15,21 +15,23 @@ class EmbroiderParams(inkex.Effect):
def __init__(self, *args, **kwargs):
inkex.Effect.__init__(self)
self.params = ["zigzag_spacing",
"stitch_length",
"row_spacing",
"max_stitch_length",
self.params = ["zigzag_spacing_mm",
"running_stitch_length_mm",
"row_spacing_mm",
"max_stitch_length_mm",
"repeats",
"angle",
"hatching",
"flip",
"satin_column",
"stroke_first",
"pull_compensation",
"satin_underlay",
"satin_underlay_inset",
"satin_center_walk",
"satin_zigzag_underlay_spacing",
"pull_compensation_mm",
"contour_underlay",
"contour_underlay_inset_mm",
"contour_underlay_stitch_length_mm",
"center_walk_underlay",
"center_walk_underlay_stitch_length_mm",
"zigzag_underlay",
"zigzag_underlay_inset_mm",
]
for param in self.params: