1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 06:57:45 +00:00

LibGfx: Implement antialiased outline ellipsis

This is a first pass at antialiased outline ellipses, currently
this is done by painting two filled AA ellipses, and then
subtracting the inner ellipse from the outer.

This produces a good result, but unfortunately requires allocating
a temporary bitmap in the painter. I did try a simpler method
using the existing line painting functions, and drawing the
ellipse as many line segments, but that produced very poor results.

I think with some work it should be possible to remove the extra
allocation, and I've left a big FIXME for this, but I could not
get this working well.
This commit is contained in:
MacDue 2022-06-01 12:13:28 +01:00 committed by Andreas Kling
parent 8ac5f625e9
commit 8c2a5bbc15
2 changed files with 53 additions and 12 deletions

View file

@ -28,8 +28,15 @@ public:
void translate(float dx, float dy) { m_transform.translate(dx, dy); }
void translate(FloatPoint const& delta) { m_transform.translate(delta); }
void fill_circle(IntPoint const& center, int radius, Color);
void fill_ellipse(IntRect const& a_rect, Color);
void draw_ellipse(IntRect const& a_rect, Color, int thickness);
enum class BlendMode {
Normal,
AlphaSubtract
};
void fill_circle(IntPoint const& center, int radius, Color, BlendMode blend_mode = BlendMode::Normal);
void fill_ellipse(IntRect const& a_rect, Color, BlendMode blend_mode = BlendMode::Normal);
void fill_rect_with_rounded_corners(IntRect const&, Color, int radius);
void fill_rect_with_rounded_corners(IntRect const&, Color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius);
@ -44,7 +51,8 @@ private:
return n >= min && n <= max;
}
};
Range draw_ellipse_part(IntPoint a_rect, int radius_a, int radius_b, Color, bool flip_x_and_y, Optional<Range> x_clip);
Range draw_ellipse_part(IntPoint a_rect, int radius_a, int radius_b, Color, bool flip_x_and_y, Optional<Range> x_clip, BlendMode blend_mode);
enum class AntiAliasPolicy {
OnlyEnds,