From f2cecc78ea16616b0f7215bd9ab014c511471b57 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Sun, 10 Jul 2022 20:37:33 +0200 Subject: [PATCH] Fix gradients with opacity set Fix #1678. --- tests/draw/svg/test_gradients.py | 31 +++++++++++++++++++++++++++++++ weasyprint/svg/defs.py | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/draw/svg/test_gradients.py b/tests/draw/svg/test_gradients.py index cd138919b..a58660cf2 100644 --- a/tests/draw/svg/test_gradients.py +++ b/tests/draw/svg/test_gradients.py @@ -490,3 +490,34 @@ def test_radial_gradient_reflect(assert_pixels): ''') + + +@assert_no_logs +def test_linear_gradient_opacity(assert_pixels): + assert_pixels(''' + BBBBBBBBBB + BBBBBBBBBB + BBBBBBBBBB + BBBBBBBBBB + BBBBBBBBBB + ssssssssss + ssssssssss + ssssssssss + ssssssssss + ssssssssss + ''', ''' + + + + + + + + + + + ''') diff --git a/weasyprint/svg/defs.py b/weasyprint/svg/defs.py index c98e682a8..34481dd9d 100644 --- a/weasyprint/svg/defs.py +++ b/weasyprint/svg/defs.py @@ -236,7 +236,7 @@ def draw_gradient(svg, node, gradient, font_size, opacity, stroke): encode = (len(colors) - 1) * (0, 1) bounds = positions[1:-1] sub_functions = ( - group.create_interpolation_function((0, 1), c0, c1, 1) + group.create_interpolation_function((0, 1), [c0], [c1], 1) for c0, c1 in alpha_couples) function = group.create_stitching_function( domain, encode, bounds, sub_functions)