summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-06-04 07:38:30 -0400
committerAndreas Kling <kling@serenityos.org>2021-06-04 19:11:45 +0200
commit4903186cc512b884df44718a2e50586632f76197 (patch)
tree6c0bd83eb080b303b6cda146b34efcdcdfb45731
parentbee1e06055234fa413034e632ec1d6a9f7d4451f (diff)
downloadserenity-4903186cc512b884df44718a2e50586632f76197.zip
LibGfx: Add helper for painting a rounded rect with equal corner radii
-rw-r--r--Userland/Libraries/LibGfx/Painter.cpp5
-rw-r--r--Userland/Libraries/LibGfx/Painter.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp
index 685d94af07..a481570022 100644
--- a/Userland/Libraries/LibGfx/Painter.cpp
+++ b/Userland/Libraries/LibGfx/Painter.cpp
@@ -247,6 +247,11 @@ void Painter::fill_rect_with_gradient(const IntRect& a_rect, Color gradient_star
return fill_rect_with_gradient(Orientation::Horizontal, a_rect, gradient_start, gradient_end);
}
+void Painter::fill_rect_with_rounded_corners(const IntRect& a_rect, Color color, int radius)
+{
+ return fill_rect_with_rounded_corners(a_rect, color, radius, radius, radius, radius);
+}
+
void Painter::fill_rect_with_rounded_corners(const IntRect& a_rect, Color color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius)
{
// Fasttrack for rects without any border radii
diff --git a/Userland/Libraries/LibGfx/Painter.h b/Userland/Libraries/LibGfx/Painter.h
index 25151bde46..7080a9effb 100644
--- a/Userland/Libraries/LibGfx/Painter.h
+++ b/Userland/Libraries/LibGfx/Painter.h
@@ -36,6 +36,7 @@ public:
void fill_rect_with_checkerboard(const IntRect&, const IntSize&, Color color_dark, Color color_light);
void fill_rect_with_gradient(Orientation, const IntRect&, Color gradient_start, Color gradient_end);
void fill_rect_with_gradient(const IntRect&, Color gradient_start, Color gradient_end);
+ void fill_rect_with_rounded_corners(const IntRect&, Color, int radius);
void fill_rect_with_rounded_corners(const IntRect&, Color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius);
void fill_ellipse(const IntRect&, Color);
void draw_rect(const IntRect&, Color, bool rough = false);