mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
LibGfx: Add Painter::fill_ellipse()
This commit is contained in:
parent
31359e3ad2
commit
8520d3a425
2 changed files with 20 additions and 0 deletions
|
@ -232,6 +232,25 @@ void Painter::fill_rect_with_gradient(const Rect& a_rect, Color gradient_start,
|
||||||
return fill_rect_with_gradient(Orientation::Horizontal, a_rect, gradient_start, gradient_end);
|
return fill_rect_with_gradient(Orientation::Horizontal, a_rect, gradient_start, gradient_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Painter::fill_ellipse(const Rect& a_rect, Color color)
|
||||||
|
{
|
||||||
|
auto rect = a_rect.translated(translation()).intersected(clip_rect());
|
||||||
|
if (rect.is_empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ASSERT(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Painter::draw_ellipse_intersecting(const Rect& rect, Color color, int thickness)
|
void Painter::draw_ellipse_intersecting(const Rect& rect, Color color, int thickness)
|
||||||
{
|
{
|
||||||
constexpr int number_samples = 100; // FIXME: dynamically work out the number of samples based upon the rect size
|
constexpr int number_samples = 100; // FIXME: dynamically work out the number of samples based upon the rect size
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
void fill_rect_with_checkerboard(const Rect&, const Size&, Color color_dark, Color color_light);
|
void fill_rect_with_checkerboard(const Rect&, const Size&, Color color_dark, Color color_light);
|
||||||
void fill_rect_with_gradient(Orientation, const Rect&, Color gradient_start, Color gradient_end);
|
void fill_rect_with_gradient(Orientation, const Rect&, Color gradient_start, Color gradient_end);
|
||||||
void fill_rect_with_gradient(const Rect&, Color gradient_start, Color gradient_end);
|
void fill_rect_with_gradient(const Rect&, Color gradient_start, Color gradient_end);
|
||||||
|
void fill_ellipse(const Rect&, Color);
|
||||||
void draw_rect(const Rect&, Color, bool rough = false);
|
void draw_rect(const Rect&, Color, bool rough = false);
|
||||||
void draw_bitmap(const Point&, const CharacterBitmap&, Color = Color());
|
void draw_bitmap(const Point&, const CharacterBitmap&, Color = Color());
|
||||||
void draw_bitmap(const Point&, const GlyphBitmap&, Color = Color());
|
void draw_bitmap(const Point&, const GlyphBitmap&, Color = Color());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue