diff options
Diffstat (limited to 'lib/elements')
| -rw-r--r-- | lib/elements/auto_fill.py | 60 | ||||
| -rw-r--r-- | lib/elements/element.py | 4 | ||||
| -rw-r--r-- | lib/elements/fill.py | 59 | ||||
| -rw-r--r-- | lib/elements/polyline.py | 10 | ||||
| -rw-r--r-- | lib/elements/satin_column.py | 72 | ||||
| -rw-r--r-- | lib/elements/stroke.py | 64 |
6 files changed, 135 insertions, 134 deletions
diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index 79220a86..cfee6d7d 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -31,11 +31,11 @@ class AutoFill(Fill): @property @param('running_stitch_length_mm', - _('Running stitch length (traversal between sections)'), - tooltip=_('Length of stitches around the outline of the fill region used when moving from section to section.'), - unit='mm', - type='float', - default=1.5) + _('Running stitch length (traversal between sections)'), + tooltip=_('Length of stitches around the outline of the fill region used when moving from section to section.'), + unit='mm', + type='float', + default=1.5) def running_stitch_length(self): return max(self.get_float_param("running_stitch_length_mm", 1.5), 0.01) @@ -46,11 +46,11 @@ class AutoFill(Fill): @property @param('fill_underlay_angle', - _('Fill angle'), - tooltip=_('default: fill angle + 90 deg'), - unit='deg', - group=_('AutoFill Underlay'), - type='float') + _('Fill angle'), + tooltip=_('default: fill angle + 90 deg'), + unit='deg', + group=_('AutoFill Underlay'), + type='float') @cache def fill_underlay_angle(self): underlay_angle = self.get_float_param("fill_underlay_angle") @@ -62,43 +62,43 @@ class AutoFill(Fill): @property @param('fill_underlay_row_spacing_mm', - _('Row spacing'), - tooltip=_('default: 3x fill row spacing'), - unit='mm', - group=_('AutoFill Underlay'), - type='float') + _('Row spacing'), + tooltip=_('default: 3x fill row spacing'), + unit='mm', + group=_('AutoFill Underlay'), + type='float') @cache def fill_underlay_row_spacing(self): return self.get_float_param("fill_underlay_row_spacing_mm") or self.row_spacing * 3 @property @param('fill_underlay_max_stitch_length_mm', - _('Max stitch length'), - tooltip=_('default: equal to fill max stitch length'), - unit='mm', - group=_('AutoFill Underlay'), type='float') + _('Max stitch length'), + tooltip=_('default: equal to fill max stitch length'), + unit='mm', + group=_('AutoFill Underlay'), type='float') @cache def fill_underlay_max_stitch_length(self): return self.get_float_param("fill_underlay_max_stitch_length_mm") or self.max_stitch_length @property @param('fill_underlay_inset_mm', - _('Inset'), - tooltip=_('Shrink the shape before doing underlay, to prevent underlay from showing around the outside of the fill.'), - unit='mm', - group=_('AutoFill Underlay'), - type='float', - default=0) + _('Inset'), + tooltip=_('Shrink the shape before doing underlay, to prevent underlay from showing around the outside of the fill.'), + unit='mm', + group=_('AutoFill Underlay'), + type='float', + default=0) def fill_underlay_inset(self): return self.get_float_param('fill_underlay_inset_mm', 0) @property @param('expand_mm', - _('Expand'), - tooltip=_('Expand the shape before fill stitching, to compensate for gaps between shapes.'), - unit='mm', - type='float', - default=0) + _('Expand'), + tooltip=_('Expand the shape before fill stitching, to compensate for gaps between shapes.'), + unit='mm', + type='float', + default=0) def expand(self): return self.get_float_param('expand_mm', 0) diff --git a/lib/elements/element.py b/lib/elements/element.py index ebca90a4..5ca70cf6 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -157,7 +157,7 @@ class EmbroideryElement(object): doc_width, doc_height = get_doc_size(svg) viewbox = svg.get('viewBox', '0 0 %s %s' % (doc_width, doc_height)) viewbox = viewbox.strip().replace(',', ' ').split() - return doc_width / float(viewbox[2]) + return doc_width / float(viewbox[2]) @property @cache @@ -230,7 +230,7 @@ class EmbroideryElement(object): return commands[0] elif len(commands) > 1: raise ValueError(_("%(id)s has more than one command of type '%(command)s' linked to it") % - dict(id=self.node.get(id), command=command)) + dict(id=self.node.get(id), command=command)) else: return None diff --git a/lib/elements/fill.py b/lib/elements/fill.py index 394f523e..672f4db8 100644 --- a/lib/elements/fill.py +++ b/lib/elements/fill.py @@ -16,21 +16,21 @@ class Fill(EmbroideryElement): @property @param('auto_fill', - _('Manually routed fill stitching'), - tooltip=_('AutoFill is the default method for generating fill stitching.'), - type='toggle', - inverse=True, - default=True) + _('Manually routed fill stitching'), + tooltip=_('AutoFill is the default method for generating fill stitching.'), + type='toggle', + inverse=True, + default=True) def auto_fill(self): return self.get_boolean_param('auto_fill', True) @property @param('angle', - _('Angle of lines of stitches'), - tooltip=_('The angle increases in a counter-clockwise direction. 0 is horizontal. Negative angles are allowed.'), - unit='deg', - type='float', - default=0) + _('Angle of lines of stitches'), + tooltip=_('The angle increases in a counter-clockwise direction. 0 is horizontal. Negative angles are allowed.'), + unit='deg', + type='float', + default=0) @cache def angle(self): return math.radians(self.get_float_param('angle', 0)) @@ -41,21 +41,22 @@ class Fill(EmbroideryElement): return self.get_style("fill", "#000000") @property - @param('flip', - _('Flip fill (start right-to-left)'), - tooltip=_('The flip option can help you with routing your stitch path. When you enable flip, stitching goes from right-to-left instead of left-to-right.'), - type='boolean', - default=False) + @param( + 'flip', + _('Flip fill (start right-to-left)'), + tooltip=_('The flip option can help you with routing your stitch path. When you enable flip, stitching goes from right-to-left instead of left-to-right.'), + type='boolean', + default=False) def flip(self): return self.get_boolean_param("flip", False) @property @param('row_spacing_mm', - _('Spacing between rows'), - tooltip=_('Distance between rows of stitches.'), - unit='mm', - type='float', - default=0.25) + _('Spacing between rows'), + tooltip=_('Distance between rows of stitches.'), + unit='mm', + type='float', + default=0.25) def row_spacing(self): return max(self.get_float_param("row_spacing_mm", 0.25), 0.1 * PIXELS_PER_MM) @@ -65,20 +66,20 @@ class Fill(EmbroideryElement): @property @param('max_stitch_length_mm', - _('Maximum fill stitch length'), - tooltip=_('The length of each stitch in a row. Shorter stitch may be used at the start or end of a row.'), - unit='mm', - type='float', - default=3.0) + _('Maximum fill stitch length'), + tooltip=_('The length of each stitch in a row. Shorter stitch may be used at the start or end of a row.'), + unit='mm', + type='float', + default=3.0) def max_stitch_length(self): return max(self.get_float_param("max_stitch_length_mm", 3.0), 0.1 * PIXELS_PER_MM) @property @param('staggers', - _('Stagger rows this many times before repeating'), - tooltip=_('Setting this dictates how many rows apart the stitches will be before they fall in the same column position.'), - type='int', - default=4) + _('Stagger rows this many times before repeating'), + tooltip=_('Setting this dictates how many rows apart the stitches will be before they fall in the same column position.'), + type='int', + default=4) def staggers(self): return self.get_int_param("staggers", 4) diff --git a/lib/elements/polyline.py b/lib/elements/polyline.py index b9ffdc0b..d3242795 100644 --- a/lib/elements/polyline.py +++ b/lib/elements/polyline.py @@ -21,13 +21,13 @@ class Polyline(EmbroideryElement): @property def points(self): - # example: "1,2 0,0 1.5,3 4,2" + # example: "1,2 0,0 1.5,3 4,2" - points = self.node.get('points') - points = points.split(" ") - points = [[float(coord) for coord in point.split(",")] for point in points] + points = self.node.get('points') + points = points.split(" ") + points = [[float(coord) for coord in point.split(",")] for point in points] - return points + return points @property @cache diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index 834509fd..e13e1118 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -29,22 +29,23 @@ class SatinColumn(EmbroideryElement): @property @param('zigzag_spacing_mm', - _('Zig-zag spacing (peak-to-peak)'), - tooltip=_('Peak-to-peak distance between zig-zags.'), - unit='mm', - type='float', - default=0.4) + _('Zig-zag spacing (peak-to-peak)'), + tooltip=_('Peak-to-peak distance between zig-zags.'), + unit='mm', + type='float', + default=0.4) def zigzag_spacing(self): # peak-to-peak distance between zigzags return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01) @property - @param('pull_compensation_mm', - _('Pull compensation'), - tooltip=_('Satin stitches pull the fabric together, resulting in a column narrower than you draw in Inkscape. This setting expands each pair of needle penetrations outward from the center of the satin column.'), - unit='mm', - type='float', - default=0) + @param( + 'pull_compensation_mm', + _('Pull compensation'), + tooltip=_('Satin stitches pull the fabric together, resulting in a column narrower than you draw in Inkscape. This setting expands each pair of needle penetrations outward from the center of the satin column.'), + unit='mm', + type='float', + default=0) def pull_compensation(self): # In satin stitch, the stitches have a tendency to pull together and # narrow the entire column. We can compensate for this by stitching @@ -65,12 +66,12 @@ class SatinColumn(EmbroideryElement): @property @param('contour_underlay_inset_mm', - _('Contour underlay inset amount'), - tooltip=_('Shrink the outline, to prevent the underlay from showing around the outside of the satin column.'), - unit='mm', - group=_('Contour Underlay'), - type='float', - default=0.4) + _('Contour underlay inset amount'), + tooltip=_('Shrink the outline, to prevent the underlay from showing around the outside of the satin column.'), + unit='mm', + group=_('Contour Underlay'), + type='float', + default=0.4) def contour_underlay_inset(self): # how far inside the edge of the column to stitch the underlay return self.get_float_param("contour_underlay_inset_mm", 0.4) @@ -94,23 +95,23 @@ class SatinColumn(EmbroideryElement): @property @param('zigzag_underlay_spacing_mm', - _('Zig-Zag spacing (peak-to-peak)'), - tooltip=_('Distance between peaks of the zig-zags.'), - unit='mm', - group=_('Zig-zag Underlay'), - type='float', - default=3) + _('Zig-Zag spacing (peak-to-peak)'), + tooltip=_('Distance between peaks of the zig-zags.'), + unit='mm', + group=_('Zig-zag Underlay'), + type='float', + default=3) def zigzag_underlay_spacing(self): return max(self.get_float_param("zigzag_underlay_spacing_mm", 3), 0.01) @property @param('zigzag_underlay_inset_mm', - _('Inset amount'), - tooltip=_('default: half of contour underlay inset'), - unit='mm', - group=_('Zig-zag Underlay'), - type='float', - default="") + _('Inset amount'), + tooltip=_('default: half of contour underlay inset'), + unit='mm', + group=_('Zig-zag Underlay'), + type='float', + default="") def zigzag_underlay_inset(self): # how far in from the edge of the satin the points in the zigzags # should be @@ -147,7 +148,6 @@ class SatinColumn(EmbroideryElement): else: return self.flatten_beziers_with_rungs() - def flatten_beziers_with_rungs(self): input_paths = [self.flatten([path]) for path in self.csp] input_paths = [shgeo.LineString(path[0]) for path in input_paths] @@ -176,16 +176,17 @@ class SatinColumn(EmbroideryElement): #print >> dbg, "rails and rungs", [str(rail) for rail in rails], [str(rung) for rung in rungs] if len(linestrings.geoms) < len(rungs.geoms) + 1: - self.fatal(_("satin column: One or more of the rungs doesn't intersect both rails.") + " " + _("Each rail should intersect both rungs once.")) + self.fatal(_("satin column: One or more of the rungs doesn't intersect both rails.") + + " " + _("Each rail should intersect both rungs once.")) elif len(linestrings.geoms) > len(rungs.geoms) + 1: - self.fatal(_("satin column: One or more of the rungs intersects the rails more than once.") + " " + _("Each rail should intersect both rungs once.")) + self.fatal(_("satin column: One or more of the rungs intersects the rails more than once.") + + " " + _("Each rail should intersect both rungs once.")) paths = [[Point(*coord) for coord in ls.coords] for ls in linestrings.geoms] result.append(paths) return zip(*result) - def simple_flatten_beziers(self): # Given a pair of paths made up of bezier segments, flatten # each individual bezier segment into line segments that approximate @@ -223,8 +224,8 @@ class SatinColumn(EmbroideryElement): if len(self.csp) == 2: if len(self.csp[0]) != len(self.csp[1]): - self.fatal(_("satin column: object %(id)s has two paths with an unequal number of points (%(length1)d and %(length2)d)") % \ - dict(id=node_id, length1=len(self.csp[0]), length2=len(self.csp[1]))) + self.fatal(_("satin column: object %(id)s has two paths with an unequal number of points (%(length1)d and %(length2)d)") % + dict(id=node_id, length1=len(self.csp[0]), length2=len(self.csp[1]))) def offset_points(self, pos1, pos2, offset_px): # Expand or contract two points about their midpoint. This is @@ -443,7 +444,6 @@ class SatinColumn(EmbroideryElement): return patch - def to_patches(self, last_patch): # Stitch a variable-width satin column, zig-zagging between two paths. diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py index e84d5e79..183ef23b 100644 --- a/lib/elements/stroke.py +++ b/lib/elements/stroke.py @@ -28,44 +28,45 @@ class Stroke(EmbroideryElement): @property @param('running_stitch_length_mm', - _('Running stitch length'), - tooltip=_('Length of stitches in running stitch mode.'), - unit='mm', - type='float', - default=1.5, - sort_index=3) + _('Running stitch length'), + tooltip=_('Length of stitches in running stitch mode.'), + unit='mm', + type='float', + default=1.5, + sort_index=3) def running_stitch_length(self): return max(self.get_float_param("running_stitch_length_mm", 1.5), 0.01) @property - @param('bean_stitch_repeats', - _('Bean stitch number of repeats'), - tooltip=_('Backtrack each stitch this many times. A value of 1 would triple each stitch (forward, back, forward). A value of 2 would quintuple each stitch, etc. Only applies to running stitch.'), - type='int', - default=0, - sort_index=2) + @param( + 'bean_stitch_repeats', + _('Bean stitch number of repeats'), + tooltip=_('Backtrack each stitch this many times. A value of 1 would triple each stitch (forward, back, forward). A value of 2 would quintuple each stitch, etc. Only applies to running stitch.'), + type='int', + default=0, + sort_index=2) def bean_stitch_repeats(self): return self.get_int_param("bean_stitch_repeats", 0) @property @param('zigzag_spacing_mm', - _('Zig-zag spacing (peak-to-peak)'), - tooltip=_('Length of stitches in zig-zag mode.'), - unit='mm', - type='float', - default=0.4, - sort_index=3) + _('Zig-zag spacing (peak-to-peak)'), + tooltip=_('Length of stitches in zig-zag mode.'), + unit='mm', + type='float', + default=0.4, + sort_index=3) @cache def zigzag_spacing(self): return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01) @property @param('repeats', - _('Repeats'), - tooltip=_('Defines how many times to run down and back along the path.'), - type='int', - default="1", - sort_index=1) + _('Repeats'), + tooltip=_('Defines how many times to run down and back along the path.'), + type='int', + default="1", + sort_index=1) def repeats(self): return self.get_int_param("repeats", 1) @@ -86,11 +87,11 @@ class Stroke(EmbroideryElement): @property @param('manual_stitch', - _('Manual stitch placement'), - tooltip=_("Stitch every node in the path. Stitch length and zig-zag spacing are ignored."), - type='boolean', - default=False, - sort_index=0) + _('Manual stitch placement'), + tooltip=_("Stitch every node in the path. Stitch length and zig-zag spacing are ignored."), + type='boolean', + default=False, + sort_index=0) def manual_stitch_mode(self): return self.get_boolean_param('manual_stitch') @@ -121,9 +122,9 @@ class Stroke(EmbroideryElement): global warned_about_legacy_running_stitch if not warned_about_legacy_running_stitch: warned_about_legacy_running_stitch = True - print >> sys.stderr, _("Legacy running stitch setting detected!\n\nIt looks like you're using a stroke " + \ - "smaller than 0.5 units to indicate a running stitch, which is deprecated. Instead, please set " + \ - "your stroke to be dashed to indicate running stitch. Any kind of dash will work.") + print >> sys.stderr, _("Legacy running stitch setting detected!\n\nIt looks like you're using a stroke " + + "smaller than 0.5 units to indicate a running stitch, which is deprecated. Instead, please set " + + "your stroke to be dashed to indicate running stitch. Any kind of dash will work.") # still allow the deprecated setting to work in order to support old files return True @@ -174,7 +175,6 @@ class Stroke(EmbroideryElement): return Patch(self.color, stitches) - def to_patches(self, last_patch): patches = [] |
