mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
LibGfx: Nudge points away from the start point in radial gradients
Avoids a division by zero, and an incorrect pixel in some repeating radial gradient cases. (Ref tests updated)
This commit is contained in:
parent
df58fa8653
commit
a98201f889
Notes:
sideshowbarker
2024-07-17 07:25:39 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/a98201f889 Pull-request: https://github.com/SerenityOS/serenity/pull/20716
4 changed files with 3 additions and 4 deletions
Binary file not shown.
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Binary file not shown.
Before Width: | Height: | Size: 859 KiB After Width: | Height: | Size: 861 KiB |
|
@ -129,7 +129,6 @@
|
|||
<rect x="0" y="0" width="400" height="300" fill="url(#reflectTest6)"></rect>
|
||||
</svg>
|
||||
<!-- spreadMethod=repeat -->
|
||||
<!-- spreadMethod=repeat -->
|
||||
<svg width="400" height="300" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<!-- Start circle inside end circle -->
|
||||
|
|
|
@ -523,9 +523,9 @@ static auto create_radial_gradient_between_two_circles(Gfx::FloatPoint start_cen
|
|||
[=](float x, float y) {
|
||||
auto loc = [&] {
|
||||
FloatPoint point { x, y };
|
||||
auto dist = point.distance_from(start_point);
|
||||
if (dist == 0)
|
||||
return 0.0f;
|
||||
// Add a little to avoid division by zero at the focal point.
|
||||
if (point == start_point)
|
||||
point += FloatPoint { 0.001f, 0.001f };
|
||||
// The "vec" (unit) vector points from the focal point to the current point.
|
||||
auto dist = point.distance_from(start_point);
|
||||
auto vec = (point - start_point) / dist;
|
||||
|
|
Loading…
Add table
Reference in a new issue