mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
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:
parent
0a120e239a
commit
d9d9103cbb
Notes:
sideshowbarker
2024-07-18 03:35:30 +09:00
Author: https://github.com/Torstennator Commit: https://github.com/SerenityOS/serenity/commit/d9d9103cbb Pull-request: https://github.com/SerenityOS/serenity/pull/18817 Reviewed-by: https://github.com/gmta ✅
3 changed files with 4 additions and 3 deletions
|
@ -99,7 +99,7 @@ void BrushTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint
|
||||||
auto falloff = get_falloff(distance) * flow_scale;
|
auto falloff = get_falloff(distance) * flow_scale;
|
||||||
auto pixel_color = color;
|
auto pixel_color = color;
|
||||||
pixel_color.set_alpha(AK::min(falloff * 255, 255));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ void EraseTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint
|
||||||
int radius = size() / 2;
|
int radius = size() / 2;
|
||||||
Gfx::IntRect rect { point.x() - radius, point.y() - radius, size(), size() };
|
Gfx::IntRect rect { point.x() - radius, point.y() - radius, size(), size() };
|
||||||
GUI::Painter painter(bitmap);
|
GUI::Painter painter(bitmap);
|
||||||
|
// FIXME: Currently this mode does not respect the editing mask if present.
|
||||||
painter.clear_rect(rect, color);
|
painter.clear_rect(rect, color);
|
||||||
} else {
|
} else {
|
||||||
for (int y = point.y() - size(); y < point.y() + size(); y++) {
|
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 old_color = bitmap.get_pixel(x, y);
|
||||||
auto falloff = get_falloff(distance);
|
auto falloff = get_falloff(distance);
|
||||||
auto new_color = old_color.interpolate(color, falloff);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ void SprayTool::paint_it()
|
||||||
continue;
|
continue;
|
||||||
if (ypos < 0 || ypos >= bitmap.height())
|
if (ypos < 0 || ypos >= bitmap.height())
|
||||||
continue;
|
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)));
|
layer->did_modify_bitmap(Gfx::IntRect::centered_on(m_last_pos, Gfx::IntSize(base_radius * 2, base_radius * 2)));
|
||||||
|
|
Loading…
Reference in a new issue