diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/Painter.cpp | 19 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Painter.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index f385e8122f..6d804410be 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -151,6 +151,25 @@ void Painter::fill_rect(IntRect const& a_rect, Color color) fill_physical_rect(rect * scale(), color); } +void Painter::fill_rect(IntRect const& rect, PaintStyle const& paint_style) +{ + auto a_rect = rect.translated(translation()); + auto clipped_rect = a_rect.intersected(clip_rect()); + if (clipped_rect.is_empty()) + return; + a_rect *= scale(); + clipped_rect *= scale(); + auto start_offset = clipped_rect.location() - a_rect.location(); + paint_style.paint(a_rect, [&](PaintStyle::SamplerFunction sample) { + for (int y = 0; y < clipped_rect.height(); ++y) { + for (int x = 0; x < clipped_rect.width(); ++x) { + IntPoint point(x, y); + set_physical_pixel(point + clipped_rect.location(), sample(point + start_offset), true); + } + } + }); +} + void Painter::fill_rect_with_dither_pattern(IntRect const& a_rect, Color color_a, Color color_b) { VERIFY(scale() == 1); // FIXME: Add scaling support. diff --git a/Userland/Libraries/LibGfx/Painter.h b/Userland/Libraries/LibGfx/Painter.h index 537c16260b..5f4804ca01 100644 --- a/Userland/Libraries/LibGfx/Painter.h +++ b/Userland/Libraries/LibGfx/Painter.h @@ -48,6 +48,7 @@ public: void clear_rect(IntRect const&, Color); void fill_rect(IntRect const&, Color); + void fill_rect(IntRect const&, PaintStyle const&); void fill_rect_with_dither_pattern(IntRect const&, Color, Color); void fill_rect_with_checkerboard(IntRect const&, IntSize, Color color_dark, Color color_light); void fill_rect_with_gradient(Orientation, IntRect const&, Color gradient_start, Color gradient_end); |