Skip to content

Commit

Permalink
LibGfx: Decrease flatness a little in Path::stroke_to_fill()
Browse files Browse the repository at this point in the history
Noticed larger stroke widths were looking a little 'low poly', this
looks a little nicer.

(Minor LibWeb test changes)
  • Loading branch information
MacDue authored and awesomekling committed Jan 21, 2024
1 parent 58df9c4 commit e9e1ee1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/LibWeb/Ref/reference/images/svg-textPath-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions Userland/Libraries/LibGfx/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit e9e1ee1

Please sign in to comment.