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

LibGfx+Userland: Rename Size::scaled_by to Size::scaled

Ignoring Size for a second, we currently have:

    Rect::scale_by
    Rect::scaled

    Point::scale_by
    Point::scaled

In Size, before this patch, we have:

    Size::scale_by
    Size::scaled_by

This aligns Size to use the same method name as Rect and Point. While
subjectively providing API symmetry, this is mostly to allow using this
method in templated helpers without caring what the exact underlying
type is.
This commit is contained in:
Timothy Flynn 2023-08-16 20:29:31 -04:00 committed by Tim Flynn
parent f34cc0b8e3
commit 7c4b0b0389
4 changed files with 7 additions and 7 deletions

View file

@ -15,7 +15,7 @@ void VectorGraphic::draw_into(Painter& painter, IntRect const& dest, AffineTrans
// This allows you to easily rotate or flip the image before painting.
auto transformed_rect = transform.map(FloatRect { {}, size() });
auto scale = min(float(dest.width()) / transformed_rect.width(), float(dest.height()) / transformed_rect.height());
auto centered = FloatRect { {}, transformed_rect.size().scaled_by(scale) }.centered_within(dest.to_type<float>());
auto centered = FloatRect { {}, transformed_rect.size().scaled(scale) }.centered_within(dest.to_type<float>());
auto view_transform = AffineTransform {}
.translate(centered.location())
.multiply(AffineTransform {}.scale(scale, scale))