1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:07:36 +00:00

LibGfx: Support alpha blending on gradients

This commit is contained in:
MacDue 2022-07-12 00:34:56 +01:00 committed by Sam Atkins
parent cbc04a6285
commit 03037cbe4e

View file

@ -255,7 +255,7 @@ void Painter::fill_rect_with_gradient(Orientation orientation, IntRect const& a_
for (int j = 0; j < clipped_rect.width(); ++j) { for (int j = 0; j < clipped_rect.width(); ++j) {
auto color = gamma_accurate_blend(gradient_start, gradient_end, c); auto color = gamma_accurate_blend(gradient_start, gradient_end, c);
color.set_alpha(c_alpha); color.set_alpha(c_alpha);
dst[j] = color.value(); dst[j] = Color::from_argb(dst[j]).blend(color).value();
c_alpha += alpha_increment; c_alpha += alpha_increment;
c += increment; c += increment;
} }
@ -268,7 +268,7 @@ void Painter::fill_rect_with_gradient(Orientation orientation, IntRect const& a_
auto color = gamma_accurate_blend(gradient_end, gradient_start, c); auto color = gamma_accurate_blend(gradient_end, gradient_start, c);
color.set_alpha(c_alpha); color.set_alpha(c_alpha);
for (int j = 0; j < clipped_rect.width(); ++j) { for (int j = 0; j < clipped_rect.width(); ++j) {
dst[j] = color.value(); dst[j] = Color::from_argb(dst[j]).blend(color).value();
} }
c_alpha += alpha_increment; c_alpha += alpha_increment;
c += increment; c += increment;