Skip to content

Commit

Permalink
Merge branch '56.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Jul 10, 2022
2 parents c378866 + f2cecc7 commit 11bc920
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions tests/draw/svg/test_gradients.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,34 @@ def test_radial_gradient_reflect(assert_pixels):
<rect x="0" y="0" width="10" height="10" fill="url(#grad)" />
</svg>
''')


@assert_no_logs
def test_linear_gradient_opacity(assert_pixels):
assert_pixels('''
BBBBBBBBBB
BBBBBBBBBB
BBBBBBBBBB
BBBBBBBBBB
BBBBBBBBBB
ssssssssss
ssssssssss
ssssssssss
ssssssssss
ssssssssss
''', '''
<style>
@page { size: 10px }
svg { display: block }
</style>
<svg width="10px" height="10px" xmlns="https://www.w3.org/2000/svg">
<defs>
<linearGradient id="grad" x1="0" y1="0" x2="0" y2="1"
gradientUnits="objectBoundingBox">
<stop stop-color="blue" offset="50%"></stop>
<stop stop-color="red" stop-opacity="0.502" offset="50%"></stop>
</linearGradient>
</defs>
<rect x="0" y="0" width="10" height="10" fill="url(#grad)" />
</svg>
''')
2 changes: 1 addition & 1 deletion weasyprint/svg/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 11bc920

Please sign in to comment.