mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:57:45 +00:00
LibWeb: Avoid NaNs from zero-length gradient color stops
This commit is contained in:
parent
f9a685437f
commit
ffdcc60b03
1 changed files with 5 additions and 1 deletions
|
@ -177,7 +177,11 @@ void paint_linear_gradient(PaintContext& context, Gfx::IntRect const& gradient_r
|
||||||
// For any given point between the two color stops,
|
// For any given point between the two color stops,
|
||||||
// determine the point’s location as a percentage of the distance between the two color stops.
|
// determine the point’s location as a percentage of the distance between the two color stops.
|
||||||
// Let this percentage be P.
|
// Let this percentage be P.
|
||||||
auto p = (position - previous_stop.position) / (next_stop.position - previous_stop.position);
|
auto stop_length = next_stop.position - previous_stop.position;
|
||||||
|
// FIXME: Avoids NaNs... Still not quite correct?
|
||||||
|
if (stop_length <= 0)
|
||||||
|
return 1;
|
||||||
|
auto p = (position - previous_stop.position) / stop_length;
|
||||||
if (!next_stop.transition_hint.has_value())
|
if (!next_stop.transition_hint.has_value())
|
||||||
return p;
|
return p;
|
||||||
if (*next_stop.transition_hint >= 1)
|
if (*next_stop.transition_hint >= 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue