From e84a86d4ac0caf29d6074728376ff0a594243fec Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Thu, 4 Mar 2021 18:40:53 +0100 Subject: Update for Inkscape 1.0 (#880) * update for inkscape 1.0 * add about extension * Build improvements for the inkscape1.0 branch (#985) * zip: export real svg not stitch plan * #411 and #726 * Tools for Font Creators (#1018) * ignore very small holes in fills * remove embroider (#1026) * auto_fill: ignore shrink_or_grow if result is empty (#589) * break apart: do not ignore small fills Co-authored-by: Hagen Fritsch Co-authored-by: Lex Neva --- lib/elements/auto_fill.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'lib/elements/auto_fill.py') diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index b574c8bf..31da7e63 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -6,10 +6,9 @@ from shapely import geometry as shgeo from ..i18n import _ from ..stitches import auto_fill -from ..utils import cache +from ..utils import cache, version from .element import Patch, param from .fill import Fill - from .validation import ValidationWarning @@ -20,6 +19,18 @@ class SmallShapeWarning(ValidationWarning): "the outline instead.") +class ExpandWarning(ValidationWarning): + name = _("Expand") + description = _("The expand parameter for this fill object cannot be applied. " + "Ink/Stitch will ignore it and will use original size instead.") + + +class UnderlayInsetWarning(ValidationWarning): + name = _("Inset") + description = _("The underlay inset parameter for this fill object cannot be applied. " + "Ink/Stitch will ignore it and will use the original size instead.") + + class AutoFill(Fill): element_name = _("AutoFill") @@ -157,9 +168,13 @@ class AutoFill(Fill): def underlay_underpath(self): return self.get_boolean_param('underlay_underpath', True) - def shrink_or_grow_shape(self, amount): + def shrink_or_grow_shape(self, amount, validate=False): if amount: shape = self.shape.buffer(amount) + # changing the size can empty the shape + # in this case we want to use the original shape rather than returning an error + if shape.is_empty and not validate: + return self.shape if not isinstance(shape, shgeo.MultiPolygon): shape = shgeo.MultiPolygon([shape]) return shape @@ -235,6 +250,7 @@ class AutoFill(Fill): # L10N this message is followed by a URL: https://github.com/inkstitch/inkstitch/issues/new message += _("If you'd like to help us make Ink/Stitch better, please paste this whole message into a new issue at: ") message += "https://github.com/inkstitch/inkstitch/issues/new\n\n" + message += version.get_inkstitch_version() + "\n\n" message += traceback.format_exc() self.fatal(message) @@ -245,5 +261,11 @@ class AutoFill(Fill): if self.shape.area < 20: yield SmallShapeWarning(self.shape.centroid) + if self.shrink_or_grow_shape(self.expand, True).is_empty: + yield ExpandWarning(self.shape.centroid) + + if self.shrink_or_grow_shape(-self.fill_underlay_inset, True).is_empty: + yield UnderlayInsetWarning(self.shape.centroid) + for warning in super(AutoFill, self).validation_warnings(): yield warning -- cgit v1.2.3