From 7bc7f376fa50b2adb805f30e42b6fa90feb47b2d Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 16 Aug 2023 20:21:59 -0400 Subject: [PATCH] LibGfx: Add Point::scaled(T) and Rect::scaled(T) Note that we already have Size::scaled(T). While subjectively providing API symmetry, this is mostly to allow using these methods in templated helpers without caring what the exact underlying type is. --- Userland/Libraries/LibGfx/Point.h | 7 +++++++ Userland/Libraries/LibGfx/Rect.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibGfx/Point.h b/Userland/Libraries/LibGfx/Point.h index 606a4162c9..545752c9d5 100644 --- a/Userland/Libraries/LibGfx/Point.h +++ b/Userland/Libraries/LibGfx/Point.h @@ -91,6 +91,13 @@ public: return point; } + [[nodiscard]] Point scaled(T dboth) const + { + Point point = *this; + point.scale_by(dboth); + return point; + } + [[nodiscard]] Point scaled(Point const& delta) const { Point point = *this; diff --git a/Userland/Libraries/LibGfx/Rect.h b/Userland/Libraries/LibGfx/Rect.h index 7a48385d28..7f53e7e7a1 100644 --- a/Userland/Libraries/LibGfx/Rect.h +++ b/Userland/Libraries/LibGfx/Rect.h @@ -177,6 +177,13 @@ public: return rect; } + [[nodiscard]] Rect scaled(T dboth) const + { + Rect rect = *this; + rect.scale_by(dboth); + return rect; + } + [[nodiscard]] Rect scaled(T sx, T sy) const { Rect rect = *this;