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
This commit is contained in:
Torstennator 2023-05-22 10:40:02 +02:00 committed by Jelle Raaijmakers
parent 0a120e239a
commit d9d9103cbb
Notes: sideshowbarker 2024-07-18 03:35:30 +09:00
3 changed files with 4 additions and 3 deletions

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -52,7 +52,7 @@ void SprayTool::paint_it()
continue;
if (ypos < 0 || ypos >= bitmap.height())
continue;
bitmap.set_pixel<Gfx::StorageFormat::BGRA8888>(xpos, ypos, m_color);
set_pixel_with_possible_mask<Gfx::StorageFormat::BGRA8888>(xpos, ypos, m_color, bitmap);
}
layer->did_modify_bitmap(Gfx::IntRect::centered_on(m_last_pos, Gfx::IntSize(base_radius * 2, base_radius * 2)));