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

LibGfx: Increase tolerance for bezier curves

An oval approximated by quadratic bezier curves ended up with 2048 line
segments when rasterized to a bitmap of around 35 by 35 pixels, which
seems a bit much. :^)

By increasing the tolerance by an order of magnitude, that same oval is
now split up into 512 line segments, which is still more than enough for
a high quality render.
This commit is contained in:
Jelle Raaijmakers 2023-04-18 23:50:40 +02:00 committed by Andreas Kling
parent 229cc67fee
commit 8f736be711

View file

@ -2116,7 +2116,7 @@ void Painter::draw_triangle_wave(IntPoint a_p1, IntPoint a_p2, Color color, int
static bool can_approximate_bezier_curve(FloatPoint p1, FloatPoint p2, FloatPoint control)
{
constexpr float tolerance = 0.0015f;
constexpr float tolerance = 0.015f;
auto p1x = 3 * control.x() - 2 * p1.x() - p2.x();
auto p1y = 3 * control.y() - 2 * p1.y() - p2.y();
@ -2190,7 +2190,7 @@ void Painter::for_each_line_segment_on_cubic_bezier_curve(FloatPoint control_poi
static bool can_approximate_cubic_bezier_curve(FloatPoint p1, FloatPoint p2, FloatPoint control_0, FloatPoint control_1)
{
constexpr float tolerance = 0.0015f;
constexpr float tolerance = 0.015f;
auto ax = 3 * control_0.x() - 2 * p1.x() - p2.x();
auto ay = 3 * control_0.y() - 2 * p1.y() - p2.y();