summaryrefslogtreecommitdiff
path: root/lib/stitches
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stitches')
-rw-r--r--lib/stitches/auto_fill.py8
-rw-r--r--lib/stitches/circular_fill.py6
-rw-r--r--lib/stitches/contour_fill.py16
-rw-r--r--lib/stitches/fill.py5
-rw-r--r--lib/stitches/guided_fill.py8
-rw-r--r--lib/stitches/ripple_stitch.py8
6 files changed, 26 insertions, 25 deletions
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py
index 5a6b7d91..d3db978a 100644
--- a/lib/stitches/auto_fill.py
+++ b/lib/stitches/auto_fill.py
@@ -80,7 +80,7 @@ def auto_fill(shape,
ending_point=None,
underpath=True,
gap_fill_rows=0,
- enable_random=False,
+ enable_random_stitch_length=False,
random_sigma=0.0,
random_seed=""):
rows = intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing)
@@ -108,7 +108,7 @@ def auto_fill(shape,
path = fill_gaps(path, round_to_multiple_of_2(gap_fill_rows))
result = path_to_stitches(shape, path, travel_graph, fill_stitch_graph, angle, row_spacing,
max_stitch_length, running_stitch_length, running_stitch_tolerance,
- staggers, skip_last, underpath, enable_random, random_sigma, random_seed)
+ staggers, skip_last, underpath, enable_random_stitch_length, random_sigma, random_seed)
return result
@@ -852,7 +852,7 @@ def travel(shape, travel_graph, edge, running_stitch_length, running_stitch_tole
@debug.time
def path_to_stitches(shape, path, travel_graph, fill_stitch_graph, angle, row_spacing, max_stitch_length, running_stitch_length,
- running_stitch_tolerance, staggers, skip_last, underpath, enable_random, random_sigma, random_seed):
+ running_stitch_tolerance, staggers, skip_last, underpath, enable_random_stitch_length, random_sigma, random_seed):
path = collapse_sequential_outline_edges(path, fill_stitch_graph)
stitches = []
@@ -864,7 +864,7 @@ def path_to_stitches(shape, path, travel_graph, fill_stitch_graph, angle, row_sp
for i, edge in enumerate(path):
if edge.is_segment():
stitch_row(stitches, edge[0], edge[1], angle, row_spacing, max_stitch_length, staggers, skip_last,
- enable_random, random_sigma, join_args(random_seed, i))
+ enable_random_stitch_length, random_sigma, join_args(random_seed, i))
# note: gap fill segments won't be in the graph
if fill_stitch_graph.has_edge(edge[0], edge[1], key='segment'):
diff --git a/lib/stitches/circular_fill.py b/lib/stitches/circular_fill.py
index 11fd0432..7be9469a 100644
--- a/lib/stitches/circular_fill.py
+++ b/lib/stitches/circular_fill.py
@@ -27,7 +27,7 @@ def circular_fill(shape,
ending_point,
underpath,
target,
- use_random,
+ enable_random_stitch_length,
running_stitch_length_jitter,
random_seed,
):
@@ -69,7 +69,7 @@ def circular_fill(shape,
stitches = running_stitch([Stitch(*point) for point in path],
running_stitch_length,
running_stitch_tolerance,
- use_random,
+ enable_random_stitch_length,
running_stitch_length_jitter,
random_seed)
return _apply_bean_stitch_and_repeats(stitches, repeats, bean_stitch_repeats)
@@ -81,7 +81,7 @@ def circular_fill(shape,
coords = running_stitch([Point(*point) for point in line.coords],
running_stitch_length,
running_stitch_tolerance,
- use_random,
+ enable_random_stitch_length,
running_stitch_length_jitter,
prng.join_args(random_seed, n))
segments.append([(point.x, point.y) for point in coords])
diff --git a/lib/stitches/contour_fill.py b/lib/stitches/contour_fill.py
index 9eea90ab..0665aacb 100644
--- a/lib/stitches/contour_fill.py
+++ b/lib/stitches/contour_fill.py
@@ -412,7 +412,7 @@ def _find_path_inner_to_outer(tree, node, offset, starting_point, avoid_self_cro
def inner_to_outer(tree, polygon, offset,
stitch_length, tolerance, smoothness,
starting_point, avoid_self_crossing,
- enable_random, random_sigma, random_seed):
+ enable_random_stitch_length, random_sigma, random_seed):
"""Fill a shape with spirals, from innermost to outermost."""
stitch_path = _find_path_inner_to_outer(tree, 'root', offset, starting_point, avoid_self_crossing)
@@ -422,7 +422,7 @@ def inner_to_outer(tree, polygon, offset,
smoothed = smooth_path(points, smoothness)
points = clamp_path_to_polygon(smoothed, polygon)
- stitches = running_stitch(points, stitch_length, tolerance, enable_random, random_sigma, random_seed)
+ stitches = running_stitch(points, stitch_length, tolerance, enable_random_stitch_length, random_sigma, random_seed)
return stitches
@@ -518,24 +518,24 @@ def _check_and_prepare_tree_for_valid_spiral(tree):
return process_node('root')
-def single_spiral(tree, stitch_length, tolerance, starting_point, enable_random, random_sigma, random_seed):
+def single_spiral(tree, stitch_length, tolerance, starting_point, enable_random_stitch_length, random_sigma, random_seed):
"""Fill a shape with a single spiral going from outside to center."""
- return _spiral_fill(tree, stitch_length, tolerance, starting_point, enable_random, random_sigma, random_seed, _make_spiral)
+ return _spiral_fill(tree, stitch_length, tolerance, starting_point, enable_random_stitch_length, random_sigma, random_seed, _make_spiral)
-def double_spiral(tree, stitch_length, tolerance, starting_point, enable_random, random_sigma, random_seed):
+def double_spiral(tree, stitch_length, tolerance, starting_point, enable_random_stitch_length, random_sigma, random_seed):
"""Fill a shape with a double spiral going from outside to center and back to outside. """
- return _spiral_fill(tree, stitch_length, tolerance, starting_point, enable_random, random_sigma, random_seed, _make_fermat_spiral)
+ return _spiral_fill(tree, stitch_length, tolerance, starting_point, enable_random_stitch_length, random_sigma, random_seed, _make_fermat_spiral)
-def _spiral_fill(tree, stitch_length, tolerance, close_point, enable_random, random_sigma, random_seed, spiral_maker):
+def _spiral_fill(tree, stitch_length, tolerance, close_point, enable_random_stitch_length, random_sigma, random_seed, spiral_maker):
starting_point = close_point.coords[0]
rings = _get_spiral_rings(tree)
path = spiral_maker(rings, stitch_length, starting_point)
path = [Stitch(*stitch) for stitch in path]
- return running_stitch(path, stitch_length, tolerance, enable_random, random_sigma, random_seed)
+ return running_stitch(path, stitch_length, tolerance, enable_random_stitch_length, random_sigma, random_seed)
def _get_spiral_rings(tree):
diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py
index 59501a9e..4f3e2208 100644
--- a/lib/stitches/fill.py
+++ b/lib/stitches/fill.py
@@ -52,12 +52,13 @@ def adjust_stagger(stitch, angle, row_spacing, max_stitch_length, staggers):
return stitch - offset * east(angle)
-def stitch_row(stitches, beg, end, angle, row_spacing, max_stitch_length, staggers, skip_last, enable_random, random_sigma, random_seed):
+def stitch_row(stitches, beg, end, angle, row_spacing, max_stitch_length, staggers, skip_last,
+ enable_random_stitch_length, random_sigma, random_seed):
beg = Stitch(*beg, tags=('fill_row_start',))
end = Stitch(*end, tags=('fill_row_start',))
stitches.append(beg)
- if enable_random:
+ if enable_random_stitch_length:
stitches += split_segment_random_phase(beg, end, max_stitch_length, random_sigma, random_seed)
else:
# We want our stitches to look like this:
diff --git a/lib/stitches/guided_fill.py b/lib/stitches/guided_fill.py
index f170f024..dcf9971a 100644
--- a/lib/stitches/guided_fill.py
+++ b/lib/stitches/guided_fill.py
@@ -35,12 +35,12 @@ def guided_fill(shape,
ending_point,
underpath,
strategy,
- enable_random,
+ enable_random_stitch_length,
random_sigma,
random_seed,
):
segments = intersect_region_with_grating_guideline(shape, guideline, row_spacing, num_staggers, max_stitch_length, strategy,
- enable_random, running_stitch_tolerance, random_sigma, random_seed,)
+ enable_random_stitch_length, running_stitch_tolerance, random_sigma, random_seed,)
if not segments:
return fallback(shape, guideline, row_spacing, max_stitch_length, running_stitch_length, running_stitch_tolerance,
num_staggers, skip_last, starting_point, ending_point, underpath)
@@ -239,7 +239,7 @@ def _get_start_row(line, shape, row_spacing, line_direction):
def intersect_region_with_grating_guideline(shape, line, row_spacing, num_staggers, max_stitch_length, strategy,
- enable_random, tolerance, random_sigma, random_seed):
+ enable_random_stitch_length, tolerance, random_sigma, random_seed):
line = prepare_guide_line(line, shape)
debug.log_line_string(shape.exterior, "guided fill shape")
@@ -271,7 +271,7 @@ def intersect_region_with_grating_guideline(shape, line, row_spacing, num_stagge
debug.log_line_string(offset_line, f"offset {row}")
- if enable_random:
+ if enable_random_stitch_length:
points = [InkstitchPoint(*x) for x in offset_line.coords]
stitched_line = shgeo.LineString(random_running_stitch(
points, max_stitch_length, tolerance, random_sigma, prng.join_args(random_seed, row)))
diff --git a/lib/stitches/ripple_stitch.py b/lib/stitches/ripple_stitch.py
index 02dbdeb2..a354166c 100644
--- a/lib/stitches/ripple_stitch.py
+++ b/lib/stitches/ripple_stitch.py
@@ -50,7 +50,7 @@ def _get_stitches(stroke, is_linear, lines, skip_start):
return running_stitch(points,
stroke.running_stitch_length,
stroke.running_stitch_tolerance,
- stroke.enable_random_stitches,
+ stroke.enable_random_stitch_length,
stroke.random_stitch_length_jitter,
stroke.random_seed)
@@ -59,7 +59,7 @@ def _get_staggered_stitches(stroke, lines, skip_start):
stitches = []
stitch_length = stroke.running_stitch_length
tolerance = stroke.running_stitch_tolerance
- enable_random = stroke.enable_random_stitches
+ enable_random_stitch_length = stroke.enable_random_stitch_length
length_sigma = stroke.random_stitch_length_jitter
random_seed = stroke.random_seed
last_point = None
@@ -77,10 +77,10 @@ def _get_staggered_stitches(stroke, lines, skip_start):
elif stroke.join_style == 1:
should_reverse = (i + skip_start) % 2 == 1
- if enable_random or stroke.staggers == 0:
+ if enable_random_stitch_length or stroke.staggers == 0:
if should_reverse:
line.reverse()
- points = running_stitch(line, stitch_length, tolerance, enable_random, length_sigma, prng.join_args(random_seed, i))
+ points = running_stitch(line, stitch_length, tolerance, enable_random_stitch_length, length_sigma, prng.join_args(random_seed, i))
stitched_line = connector + points
else:
# uses the guided fill alforithm to stagger rows of stitches