Просмотр исходного кода

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.
Timothy Flynn 1 год назад
Родитель
Сommit
7bc7f376fa
2 измененных файлов с 14 добавлено и 0 удалено
  1. 7 0
      Userland/Libraries/LibGfx/Point.h
  2. 7 0
      Userland/Libraries/LibGfx/Rect.h

+ 7 - 0
Userland/Libraries/LibGfx/Point.h

@@ -91,6 +91,13 @@ public:
         return point;
     }
 
+    [[nodiscard]] Point<T> scaled(T dboth) const
+    {
+        Point<T> point = *this;
+        point.scale_by(dboth);
+        return point;
+    }
+
     [[nodiscard]] Point<T> scaled(Point<T> const& delta) const
     {
         Point<T> point = *this;

+ 7 - 0
Userland/Libraries/LibGfx/Rect.h

@@ -177,6 +177,13 @@ public:
         return rect;
     }
 
+    [[nodiscard]] Rect<T> scaled(T dboth) const
+    {
+        Rect<T> rect = *this;
+        rect.scale_by(dboth);
+        return rect;
+    }
+
     [[nodiscard]] Rect<T> scaled(T sx, T sy) const
     {
         Rect<T> rect = *this;