diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2018-06-15 21:42:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-15 21:42:52 -0400 |
| commit | 28e8efebf2a721239fa996865f9ef228e3521121 (patch) | |
| tree | 89526b299ab2e55bb69225d26cea781f90bc9bd1 /lib/elements | |
| parent | 4a2162e25892da7ce49b944532ebc8f2a9786a28 (diff) | |
| parent | 350c292f8d0415fefefa83ce5ce84c2b5c17bd75 (diff) | |
v1.9.1: bug fixes
Lots of bug fixes:
* properly handle case where stroke width is not set (defaults to 1 per SVG spec)
* properly handle case where <svg> width and height not set (defaults to viewbox)
* properly handle case where fill is not set (defaults to "black" rather than "none")
* show error message (rather than crashing) if satin column set for a path with only one subpath
* don't leave the simulate window around after "use last settings"
* show a useful error message in Params if the user hasn't selected anything embroiderable
Diffstat (limited to 'lib/elements')
| -rw-r--r-- | lib/elements/element.py | 6 | ||||
| -rw-r--r-- | lib/elements/fill.py | 3 | ||||
| -rw-r--r-- | lib/elements/satin_column.py | 2 | ||||
| -rw-r--r-- | lib/elements/stroke.py | 5 |
4 files changed, 8 insertions, 8 deletions
diff --git a/lib/elements/element.py b/lib/elements/element.py index 42f6c470..39437c9f 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -135,10 +135,10 @@ class EmbroideryElement(object): self.node.set("embroider_%s" % name, str(value)) @cache - def get_style(self, style_name): + def get_style(self, style_name, default=None): style = simplestyle.parseStyle(self.node.get("style")) if (style_name not in style): - return None + return default value = style[style_name] if value == 'none': return None @@ -161,7 +161,7 @@ class EmbroideryElement(object): @property @cache def stroke_width(self): - width = self.get_style("stroke-width") + width = self.get_style("stroke-width", "1") if width is None: return 1.0 diff --git a/lib/elements/fill.py b/lib/elements/fill.py index 52a42260..8d1d35f2 100644 --- a/lib/elements/fill.py +++ b/lib/elements/fill.py @@ -27,7 +27,8 @@ class Fill(EmbroideryElement): @property def color(self): - return self.get_style("fill") + # SVG spec says the default fill is black + return self.get_style("fill", "#000000") @property @param('flip', _('Flip fill (start right-to-left)'), type='boolean', default=False) diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index 3593db64..1d13c5e0 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -97,6 +97,8 @@ class SatinColumn(EmbroideryElement): def flattened_beziers(self): if len(self.csp) == 2: return self.simple_flatten_beziers() + elif len(self.csp) < 2: + self.fatal(_("satin column: %(id)s: at least two subpaths required (%(num)d found)") % dict(num=len(self.csp), id=self.node.get('id'))) else: return self.flatten_beziers_with_rungs() diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py index d3054132..5239f978 100644 --- a/lib/elements/stroke.py +++ b/lib/elements/stroke.py @@ -57,10 +57,7 @@ class Stroke(EmbroideryElement): def is_running_stitch(self): # using stroke width <= 0.5 pixels to indicate running stitch is deprecated in favor of dashed lines - try: - stroke_width = float(self.get_style("stroke-width")) - except ValueError: - stroke_width = 1 + stroke_width = float(self.get_style("stroke-width", 1)) if self.dashed: return True |
