1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-09-11 20:47:56 +03:00

Merge branch '56.x'

This commit is contained in:
Guillaume Ayoub 2022-07-10 20:38:07 +02:00
commit 11bc920910
2 changed files with 32 additions and 1 deletions

View File

@ -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>
''')

View File

@ -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)