diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2021-03-04 18:40:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-04 18:40:53 +0100 |
| commit | e84a86d4ac0caf29d6074728376ff0a594243fec (patch) | |
| tree | 888c79ed0094ba2916a1d329861a85515959913c /lib/extensions/break_apart.py | |
| parent | b39575a50191307b3b56eab6455626398eec6397 (diff) | |
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 <rumpeltux-github@irgendwo.org>
Co-authored-by: Lex Neva <github.com@lexneva.name>
Diffstat (limited to 'lib/extensions/break_apart.py')
| -rw-r--r-- | lib/extensions/break_apart.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/extensions/break_apart.py b/lib/extensions/break_apart.py index 0b17d3d7..d0ab2619 100644 --- a/lib/extensions/break_apart.py +++ b/lib/extensions/break_apart.py @@ -1,11 +1,10 @@ import logging from copy import copy +import inkex from shapely.geometry import LineString, MultiPolygon, Polygon from shapely.ops import polygonize, unary_union -import inkex - from ..elements import EmbroideryElement from ..i18n import _ from ..svg import get_correction_transform @@ -19,10 +18,11 @@ class BreakApart(InkstitchExtension): ''' def __init__(self, *args, **kwargs): InkstitchExtension.__init__(self, *args, **kwargs) - self.OptionParser.add_option("-m", "--method", type="int", default=1, dest="method") + self.arg_parser.add_argument("-m", "--method", type=int, default=1, dest="method") + self.minimum_size = 5 def effect(self): # noqa: C901 - if not self.selected: + if not self.svg.selected: inkex.errormsg(_("Please select one or more fill areas to break apart.")) return @@ -41,13 +41,12 @@ class BreakApart(InkstitchExtension): try: paths.sort(key=lambda point_list: Polygon(point_list).area, reverse=True) polygon = MultiPolygon([(paths[0], paths[1:])]) - if self.geom_is_valid(polygon): + if self.geom_is_valid(polygon) and Polygon(paths[-1]).area > self.minimum_size: continue except ValueError: pass polygons = self.break_apart_paths(paths) - polygons = self.ensure_minimum_size(polygons, 5) if self.options.method == 1: polygons = self.combine_overlapping_polygons(polygons) polygons = self.recombine_polygons(polygons) @@ -106,6 +105,7 @@ class BreakApart(InkstitchExtension): polygons.sort(key=lambda polygon: polygon.area, reverse=True) multipolygons = [] holes = [] + self.ensure_minimum_size(polygons, self.minimum_size) for polygon in polygons: if polygon in holes: continue |
