LibGfx: Decrease flatness a little in Path::stroke_to_fill()

Noticed larger stroke widths were looking a little 'low poly', this
looks a little nicer.

(Minor LibWeb test changes)
This commit is contained in:
MacDue 2024-01-21 15:17:52 +00:00 committed by Andreas Kling
parent 58df9c45b9
commit e9e1ee11d4
3 changed files with 9 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -513,11 +513,15 @@ Path Path::stroke_to_fill(float thickness) const
}
}
// Note: This is the same as the tolerance from bezier curve splitting.
constexpr auto flatness = 0.5f;
auto pen_vertex_count = (thickness >= 2 * flatness) ? max(
static_cast<int>(ceilf(AK::Pi<float> / acosf(1 - (2 * flatness) / thickness))), 4)
: 4;
constexpr auto flatness = 0.15f;
auto pen_vertex_count = 4;
if (thickness > flatness) {
pen_vertex_count = max(
static_cast<int>(ceilf(AK::Pi<float>
/ acosf(1 - (2 * flatness) / thickness))),
pen_vertex_count);
}
if (pen_vertex_count % 2 == 1)
pen_vertex_count += 1;