1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 10:47:35 +00:00

LibGfx: AntiAliasingPainter::draw_circle/fill_rect_with_rounded_corners

Follows the efficient algorithm from this paper:
https://cs.uwaterloo.ca/research/tr/1984/CS-84-38.pdf

Can be extended ellipses in future.
This commit is contained in:
MacDue 2022-03-10 02:21:02 +00:00 committed by Andreas Kling
parent 913374163c
commit 51e54ab1ba
4 changed files with 238 additions and 4 deletions

View file

@ -1683,7 +1683,7 @@ void Painter::draw_text(Function<void(IntRect const&, Utf8CodePointIterator&)> d
});
}
void Painter::set_pixel(IntPoint const& p, Color color)
void Painter::set_pixel(IntPoint const& p, Color color, bool blend)
{
VERIFY(scale() == 1); // FIXME: Add scaling support.
@ -1691,7 +1691,12 @@ void Painter::set_pixel(IntPoint const& p, Color color)
point.translate_by(state().translation);
if (!clip_rect().contains(point))
return;
m_target->scanline(point.y())[point.x()] = color.value();
auto& dst = m_target->scanline(point.y())[point.x()];
if (!blend) {
dst = color.value();
} else {
dst = Color::from_argb(dst).blend(color).value();
}
}
ALWAYS_INLINE void Painter::set_physical_pixel_with_draw_op(u32& pixel, Color const& color)