mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:07:34 +00:00
LibGfx: Fix off-by-one for antialiased line length
Previously the line did not include the endpoint.
This commit is contained in:
parent
754b8a643d
commit
8dfe43273c
1 changed files with 5 additions and 4 deletions
|
@ -44,7 +44,8 @@ void AntiAliasingPainter::draw_anti_aliased_line(FloatPoint actual_from, FloatPo
|
||||||
int int_thickness = AK::ceil(thickness);
|
int int_thickness = AK::ceil(thickness);
|
||||||
auto mapped_from = m_transform.map(actual_from);
|
auto mapped_from = m_transform.map(actual_from);
|
||||||
auto mapped_to = m_transform.map(actual_to);
|
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:
|
// Axis-aligned lines:
|
||||||
if (mapped_from.y() == mapped_to.y()) {
|
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) {
|
if constexpr (path_hacks == FixmeEnableHacksForBetterPathPainting::Yes) {
|
||||||
// FIXME: SVG stoke_path() hack:
|
// FIXME: SVG stoke_path() hack:
|
||||||
// When painting stokes SVG asks for many thickness * < 1px lines.
|
// When painting stokes SVG asks for many very short lines...
|
||||||
// It actually wants a thickness * thickness dot centered at that point.
|
// These look better just painted as dots/AA rectangles
|
||||||
// (Technically this should be rotated or a circle, but that currently gives worse results)
|
// (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);
|
return fill_rect(Gfx::FloatRect::centered_at(mapped_from, { thickness, thickness }), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue