1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

LibGfx: Be more aggressive when splitting bezier curves

Significantly reduce the tolerance when splitting bezier curves. This
gives a smoother final appearance at the cost of drawing more lines.
This commit is contained in:
Andreas Kling 2022-03-19 20:51:40 +01:00
parent 0b861e0c9d
commit d09e8978c2

View file

@ -1925,7 +1925,7 @@ void Painter::draw_triangle_wave(IntPoint const& a_p1, IntPoint const& a_p2, Col
static bool can_approximate_bezier_curve(FloatPoint const& p1, FloatPoint const& p2, FloatPoint const& control)
{
constexpr static int tolerance = 15;
constexpr float tolerance = 0.0015f;
auto p1x = 3 * control.x() - 2 * p1.x() - p2.x();
auto p1y = 3 * control.y() - 2 * p1.y() - p2.y();
@ -1999,7 +1999,7 @@ void Painter::for_each_line_segment_on_cubic_bezier_curve(FloatPoint const& cont
static bool can_approximate_cubic_bezier_curve(FloatPoint const& p1, FloatPoint const& p2, FloatPoint const& control_0, FloatPoint const& control_1)
{
constexpr float tolerance = 15; // Arbitrary, seems like 10-30 produces nice results.
constexpr float tolerance = 0.0015f;
auto ax = 3 * control_0.x() - 2 * p1.x() - p2.x();
auto ay = 3 * control_0.y() - 2 * p1.y() - p2.y();