1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +00:00

PixelPaint: Let PickerTool optionally sample all layers

Previously, only the color from the selected layer would be picked.
Now, we allow the user to select if they want to sample the color
from all layers.
This commit is contained in:
Mustafa Quraish 2021-09-01 00:12:15 -04:00 committed by Andreas Kling
parent 640a980080
commit 2afa28d297
4 changed files with 58 additions and 7 deletions

View file

@ -532,4 +532,19 @@ void Image::crop(Gfx::IntRect const& cropped_rect)
did_change_rect(cropped_rect);
}
Color Image::color_at(Gfx::IntPoint const& point) const
{
Color color;
for (auto& layer : m_layers) {
if (!layer.is_visible() || !layer.rect().contains(point))
continue;
auto layer_color = layer.bitmap().get_pixel(point);
float layer_opacity = layer.opacity_percent() / 100.0f;
layer_color.set_alpha((u8)(layer_color.alpha() * layer_opacity));
color = color.blend(layer_color);
}
return color;
}
}