summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2022-11-29 23:53:46 +0000
committerAndreas Kling <kling@serenityos.org>2022-11-30 07:58:44 +0100
commit8dfe43273cd7069a7c5583118b118bab1ebb5c69 (patch)
treebbadc5b6f74ea1c592710da271bec27706aff4fd
parent754b8a643d9598c1e145d26e14c6420bd4a3a209 (diff)
downloadserenity-8dfe43273cd7069a7c5583118b118bab1ebb5c69.zip
LibGfx: Fix off-by-one for antialiased line length
Previously the line did not include the endpoint.
-rw-r--r--Userland/Libraries/LibGfx/AntiAliasingPainter.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
index 6efa0af28b..75ff3c12b0 100644
--- a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
+++ b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
@@ -44,7 +44,8 @@ void AntiAliasingPainter::draw_anti_aliased_line(FloatPoint actual_from, FloatPo
int int_thickness = AK::ceil(thickness);
auto mapped_from = m_transform.map(actual_from);
auto mapped_to = m_transform.map(actual_to);
- auto length = mapped_to.distance_from(mapped_from);
+ auto distance = mapped_to.distance_from(mapped_from);
+ auto length = distance + 1;
// Axis-aligned lines:
if (mapped_from.y() == mapped_to.y()) {
@@ -63,10 +64,10 @@ void AntiAliasingPainter::draw_anti_aliased_line(FloatPoint actual_from, FloatPo
if constexpr (path_hacks == FixmeEnableHacksForBetterPathPainting::Yes) {
// FIXME: SVG stoke_path() hack:
- // When painting stokes SVG asks for many thickness * < 1px lines.
- // It actually wants a thickness * thickness dot centered at that point.
+ // When painting stokes SVG asks for many very short lines...
+ // These look better just painted as dots/AA rectangles
// (Technically this should be rotated or a circle, but that currently gives worse results)
- if (length < 1.0f)
+ if (distance < 1.0f)
return fill_rect(Gfx::FloatRect::centered_at(mapped_from, { thickness, thickness }), color);
}