From 952ba0023a2b70de5fd7e5b2bb0d06566ec214e5 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Tue, 4 Jun 2024 22:27:33 +0200 Subject: Update tartan gui (#2965) * update tartan gui * params settings size * fix issue with set_precision * fix issue with linear gradient * do not add ignore layer command to png rerealistic output --- lib/stitches/linear_gradient_fill.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'lib/stitches') diff --git a/lib/stitches/linear_gradient_fill.py b/lib/stitches/linear_gradient_fill.py index e72161ca..ea248d98 100644 --- a/lib/stitches/linear_gradient_fill.py +++ b/lib/stitches/linear_gradient_fill.py @@ -66,7 +66,17 @@ def _get_gradient_info(fill, bbox): else: fill.gradient.apply_transform() offsets = fill.gradient.stop_offsets - colors = [style['stop-color'] if float(style['stop-opacity']) > 0 else 'none' for style in fill.gradient.stop_styles] + # get stop colors + # it would be easier if we just used fill.gradient.stop_styles to collect them + # but inkex/tinycss fails on stop color styles when it is not in the style attribute, but in it's own stop-color attribute + colors = [] + for stop in fill.gradient.stops: + color = stop.get_computed_style('stop-color') + opacity = stop.get_computed_style('stop-opacity') + if float(opacity) > 0: + colors.append(color) + else: + colors.append('none') gradient_start, gradient_end = gradient_start_end(fill.node, fill.gradient) angle = gradient_angle(fill.node, fill.gradient) return angle, colors, offsets, Point(list(gradient_start)), Point(list(gradient_end)) @@ -167,6 +177,7 @@ def _get_color_lines(lines, colors, stop_color_line_indices): c2_count = 0 c1_count = 0 + max_count = 1000 current_line = 0 line_count_diff = floor((total_lines - sections**2) / 2) @@ -181,7 +192,7 @@ def _get_color_lines(lines, colors, stop_color_line_indices): rest = c1_count % c2_count c1_count = ceil(c1_count / c2_count) - current_line, line_count_diff, color1, color2, stop = _add_lines( + current_line, line_count_diff, color1, color2, max_count, stop = _add_lines( current_line, total_lines, line_count_diff, @@ -190,7 +201,8 @@ def _get_color_lines(lines, colors, stop_color_line_indices): stop, rest, c1_count, - c2_count + c2_count, + max_count ) # mirror the first half of the color section to receive the full section @@ -232,10 +244,11 @@ def _get_color_lines(lines, colors, stop_color_line_indices): return color_lines, colors -def _add_lines(current_line, total_lines, line_count_diff, color1, color2, stop, rest, c1_count, c2_count): +def _add_lines(current_line, total_lines, line_count_diff, color1, color2, stop, rest, c1_count, c2_count, max_count): for j in range(c2_count): if stop: break + if rest == 0 or j < rest: count = c1_count else: @@ -243,6 +256,8 @@ def _add_lines(current_line, total_lines, line_count_diff, color1, color2, stop, if line_count_diff > 0: count += 1 line_count_diff -= 1 + count = min(count, max_count) + for k in range(count): color1.append(current_line) current_line += 1 @@ -251,7 +266,8 @@ def _add_lines(current_line, total_lines, line_count_diff, color1, color2, stop, break color2.append(current_line) current_line += 1 - return current_line, line_count_diff, color1, color2, stop + max_count = count + return current_line, line_count_diff, color1, color2, max_count, stop def _get_stitch_groups(fill, shape, colors, color_lines, starting_point, ending_point): -- cgit v1.2.3