summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Painter.cpp
diff options
context:
space:
mode:
authorEgor Ananyin <ananinegor@gmail.com>2021-05-08 20:15:03 +0300
committerLinus Groh <mail@linusgroh.de>2021-05-09 16:14:01 +0100
commit782dc348fd21a17eccf255bc4797cdc10b71bed5 (patch)
tree279d714007fba319ef699a71d84d20f5f529eec5 /Userland/Libraries/LibGfx/Painter.cpp
parent5eb062d8d3f5f74102662cb7c3f6016afa6d6396 (diff)
downloadserenity-782dc348fd21a17eccf255bc4797cdc10b71bed5.zip
LibGfx: Fix clipping in fill_ellipse
fill_ellipse used to clip the bounding box, so instead of drawing a part of an ellipse it drew a smaller ellipse. This commit fixes this behaviour.
Diffstat (limited to 'Userland/Libraries/LibGfx/Painter.cpp')
-rw-r--r--Userland/Libraries/LibGfx/Painter.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp
index ff4e31f603..5ec78c6e01 100644
--- a/Userland/Libraries/LibGfx/Painter.cpp
+++ b/Userland/Libraries/LibGfx/Painter.cpp
@@ -255,14 +255,10 @@ void Painter::fill_ellipse(const IntRect& a_rect, Color color)
VERIFY(m_target->rect().contains(rect));
- RGBA32* dst = m_target->scanline(rect.top()) + rect.left() + rect.width() / 2;
- const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
-
- for (int i = 0; i < rect.height(); i++) {
- double y = rect.height() * 0.5 - i;
- double x = rect.width() * sqrt(0.25 - y * y / rect.height() / rect.height());
- fast_u32_fill(dst - (int)x, color.value(), 2 * (int)x);
- dst += dst_skip;
+ for (int i = 1; i < a_rect.height(); i++) {
+ double y = a_rect.height() * 0.5 - i;
+ double x = a_rect.width() * sqrt(0.25 - y * y / a_rect.height() / a_rect.height());
+ draw_line({ a_rect.x() + a_rect.width() / 2 - (int)x, a_rect.y() + i }, { a_rect.x() + a_rect.width() / 2 + (int)x - 1, a_rect.y() + i }, color);
}
}