diff options
| author | Lex Neva <github.com@lexneva.name> | 2023-02-05 22:58:17 -0500 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2023-02-20 15:27:55 -0500 |
| commit | 8dde33d867afce7ea4aa212dfce60e9e526bbc1c (patch) | |
| tree | dbde1b5e348f89520f91defecce568628470c632 /lib/stitches | |
| parent | 39b3db0165e947f317f181f6e4498f496957e57e (diff) | |
make meander interruptible
Diffstat (limited to 'lib/stitches')
| -rw-r--r-- | lib/stitches/meander_fill.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/stitches/meander_fill.py b/lib/stitches/meander_fill.py index 6b3df0e3..5f399158 100644 --- a/lib/stitches/meander_fill.py +++ b/lib/stitches/meander_fill.py @@ -10,6 +10,7 @@ from ..utils import smooth_path from ..utils.geometry import Point as InkStitchPoint, ensure_geometry_collection from ..utils.list import poprandom from ..utils.prng import iter_uniform_floats +from ..utils.threading import check_stop_flag def meander_fill(fill, shape, shape_index, starting_point, ending_point): @@ -83,11 +84,15 @@ def generate_meander_path(graph, start, end, rng): meander_path = path_edges while edges_to_consider: while edges_to_consider: + check_stop_flag() + edge = poprandom(edges_to_consider, rng) edges_to_consider.extend(replace_edge(meander_path, edge, graph, graph_nodes)) edge_pairs = list(zip(meander_path[:-1], meander_path[1:])) while edge_pairs: + check_stop_flag() + edge1, edge2 = poprandom(edge_pairs, rng) edges_to_consider.extend(replace_edge_pair(meander_path, edge1, edge2, graph, graph_nodes)) break |
