mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
PixelPaint: Make Resize Image scale each layer to the correct size
The "Resize Image" action will now scale layer such that the corners of each layer maintain their position relative to the edge of the canvas. Previously, each layer was scaled to the same size of the canvas.
This commit is contained in:
parent
92a0a7e3fa
commit
c17b32e058
1 changed files with 5 additions and 2 deletions
|
@ -677,8 +677,11 @@ ErrorOr<void> Image::resize(Gfx::IntSize new_size, Gfx::Painter::ScalingMode sca
|
||||||
if (layer->is_selected())
|
if (layer->is_selected())
|
||||||
selected_layer_index = i;
|
selected_layer_index = i;
|
||||||
|
|
||||||
Gfx::IntPoint new_location(scale_x * new_layer->location().x(), scale_y * new_layer->location().y());
|
auto layer_rect = layer->relative_rect().to_type<float>();
|
||||||
TRY(new_layer->resize(new_size, new_location, scaling_mode, Layer::NotifyClients::No));
|
auto scaled_top_left = layer_rect.top_left().scaled(scale_x, scale_y).to_rounded<int>();
|
||||||
|
auto scaled_bottom_right = layer_rect.bottom_right().translated(1).scaled(scale_x, scale_y).to_rounded<int>();
|
||||||
|
auto scaled_layer_rect = Gfx::IntRect::from_two_points(scaled_top_left, scaled_bottom_right);
|
||||||
|
TRY(new_layer->resize(scaled_layer_rect, scaling_mode, Layer::NotifyClients::No));
|
||||||
|
|
||||||
resized_layers.unchecked_append(new_layer);
|
resized_layers.unchecked_append(new_layer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue