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

LibGfx: Implement AntiAliasingPainter::draw_ellipse()

This commit adds draw_ellipse() and moves the shared code
for circles and ellipses to draw_ellipse_part().

draw_ellipse_part() can draw an entire circle in one call using
8-way symmetry and an ellipse in two calls using 4-way symmetry.
This commit is contained in:
MacDue 2022-03-21 01:46:46 +00:00 committed by Linus Groh
parent 6e52e6b554
commit 60aba4c9f3
3 changed files with 113 additions and 36 deletions

View file

@ -28,11 +28,23 @@ public:
void translate(float dx, float dy) { m_transform.translate(dx, dy); }
void translate(FloatPoint const& delta) { m_transform.translate(delta); }
void draw_circle(IntPoint center, int radius, Color);
void draw_circle(IntPoint const& center, int radius, Color);
void draw_ellipse(IntRect const& a_rect, Color);
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);
private:
struct Range {
int min;
int max;
inline bool contains_inclusive(int n) const
{
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);
enum class AntiAliasPolicy {
OnlyEnds,
Full,