Skip to content

Commit

Permalink
Fix hsl and hwb colors in gradients
Browse files Browse the repository at this point in the history
This commit doesn’t add support for non-sRGB color spaces.

Fix #2360.
  • Loading branch information
liZe committed Jan 24, 2025
1 parent f992fd5 commit 80129e2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions weasyprint/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ def get_intrinsic_size(self, image_resolution, font_size):
return None, None, None

def draw(self, stream, concrete_width, concrete_height, _image_rendering):
# TODO: handle color spaces
scale_y, type_, points, positions, colors = self.layout(
concrete_width, concrete_height)

Expand All @@ -500,8 +499,9 @@ def draw(self, stream, concrete_width, concrete_height, _image_rendering):
alpha_couples = [
(alphas[i], alphas[i + 1])
for i in range(len(alphas) - 1)]
# TODO: handle other color spaces.
color_couples = [
[colors[i][:3], colors[i + 1][:3], 1]
[colors[i].to('srgb')[:3], colors[i + 1].to('srgb')[:3], 1]
for i in range(len(colors) - 1)]

# Premultiply colors
Expand All @@ -525,6 +525,7 @@ def draw(self, stream, concrete_width, concrete_height, _image_rendering):
for c0, c1, n in color_couples)
function = stream.create_stitching_function(
domain, encode, bounds, sub_functions)
# TODO: handle other color spaces.
shading = stream.add_shading(
shading_type, 'RGB', domain, points, extend, function)
stream.transform(d=scale_y)
Expand Down

0 comments on commit 80129e2

Please sign in to comment.