From d9d9103cbb43e6a2edcfc89ad070269687aba82a Mon Sep 17 00:00:00 2001 From: Torstennator Date: Mon, 22 May 2023 10:40:02 +0200 Subject: [PATCH] PixelPaint: Start using Editing-Masks for some tools This patch starts to integrate the usage of Editing-Masks for the following tools: Spray-Tool, Brush-Tool and Erase-Tool --- Userland/Applications/PixelPaint/Tools/BrushTool.cpp | 2 +- Userland/Applications/PixelPaint/Tools/EraseTool.cpp | 3 ++- Userland/Applications/PixelPaint/Tools/SprayTool.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Applications/PixelPaint/Tools/BrushTool.cpp b/Userland/Applications/PixelPaint/Tools/BrushTool.cpp index 3fe39457e3..8fb1f9abeb 100644 --- a/Userland/Applications/PixelPaint/Tools/BrushTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/BrushTool.cpp @@ -99,7 +99,7 @@ void BrushTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint auto falloff = get_falloff(distance) * flow_scale; auto pixel_color = color; pixel_color.set_alpha(AK::min(falloff * 255, 255)); - bitmap.set_pixel(x, y, bitmap.get_pixel(x, y).blend(pixel_color)); + set_pixel_with_possible_mask(x, y, bitmap.get_pixel(x, y).blend(pixel_color), bitmap); } } } diff --git a/Userland/Applications/PixelPaint/Tools/EraseTool.cpp b/Userland/Applications/PixelPaint/Tools/EraseTool.cpp index 924912b504..315724ee04 100644 --- a/Userland/Applications/PixelPaint/Tools/EraseTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/EraseTool.cpp @@ -34,6 +34,7 @@ void EraseTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint int radius = size() / 2; Gfx::IntRect rect { point.x() - radius, point.y() - radius, size(), size() }; GUI::Painter painter(bitmap); + // FIXME: Currently this mode does not respect the editing mask if present. painter.clear_rect(rect, color); } else { for (int y = point.y() - size(); y < point.y() + size(); y++) { @@ -47,7 +48,7 @@ void EraseTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint auto old_color = bitmap.get_pixel(x, y); auto falloff = get_falloff(distance); auto new_color = old_color.interpolate(color, falloff); - bitmap.set_pixel(x, y, new_color); + set_pixel_with_possible_mask(x, y, new_color, bitmap); } } } diff --git a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp index f249a4f736..45750615e4 100644 --- a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp @@ -52,7 +52,7 @@ void SprayTool::paint_it() continue; if (ypos < 0 || ypos >= bitmap.height()) continue; - bitmap.set_pixel(xpos, ypos, m_color); + set_pixel_with_possible_mask(xpos, ypos, m_color, bitmap); } layer->did_modify_bitmap(Gfx::IntRect::centered_on(m_last_pos, Gfx::IntSize(base_radius * 2, base_radius * 2)));