diff --git a/Siv3D/include/Siv3D/Rect.hpp b/Siv3D/include/Siv3D/Rect.hpp index 1a54ab015..cae41b378 100644 --- a/Siv3D/include/Siv3D/Rect.hpp +++ b/Siv3D/include/Siv3D/Rect.hpp @@ -524,6 +524,30 @@ namespace s3d [[nodiscard]] constexpr Rect stretched(value_type top, value_type right, value_type bottom, value_type left) const noexcept; + /// @brief 上方向に拡大縮小した長方形を返します。 + /// @param top 上方向の拡大縮小量 + /// @return 上方向に拡大縮小した長方形 + [[nodiscard]] + constexpr Rect stretched(Arg::top_ top) const noexcept; + + /// @brief 右方向に拡大縮小した長方形を返します。 + /// @param right 右方向の拡大縮小量 + /// @return 右方向に拡大縮小した長方形 + [[nodiscard]] + constexpr Rect stretched(Arg::right_ right) const noexcept; + + /// @brief 下方向に拡大縮小した長方形を返します。 + /// @param bottom 下方向の拡大縮小量 + /// @return 下方向に拡大縮小した長方形 + [[nodiscard]] + constexpr Rect stretched(Arg::bottom_ bottom) const noexcept; + + /// @brief 左方向に拡大縮小した長方形を返します。 + /// @param left 左方向の拡大縮小量 + /// @return 左方向に拡大縮小した長方形 + [[nodiscard]] + constexpr Rect stretched(Arg::left_ left) const noexcept; + [[nodiscard]] constexpr RectF scaled(double s) const noexcept; diff --git a/Siv3D/include/Siv3D/RectF.hpp b/Siv3D/include/Siv3D/RectF.hpp index 18721b5d2..d7110ead7 100644 --- a/Siv3D/include/Siv3D/RectF.hpp +++ b/Siv3D/include/Siv3D/RectF.hpp @@ -576,6 +576,30 @@ namespace s3d [[nodiscard]] constexpr RectF stretched(value_type top, value_type right, value_type bottom, value_type left) const noexcept; + /// @brief 上方向に拡大縮小した長方形を返します。 + /// @param top 上方向の拡大縮小量 + /// @return 上方向に拡大縮小した長方形 + [[nodiscard]] + constexpr RectF stretched(Arg::top_ top) const noexcept; + + /// @brief 右方向に拡大縮小した長方形を返します。 + /// @param right 右方向の拡大縮小量 + /// @return 右方向に拡大縮小した長方形 + [[nodiscard]] + constexpr RectF stretched(Arg::right_ right) const noexcept; + + /// @brief 下方向に拡大縮小した長方形を返します。 + /// @param bottom 下方向の拡大縮小量 + /// @return 下方向に拡大縮小した長方形 + [[nodiscard]] + constexpr RectF stretched(Arg::bottom_ bottom) const noexcept; + + /// @brief 左方向に拡大縮小した長方形を返します。 + /// @param left 左方向の拡大縮小量 + /// @return 左方向に拡大縮小した長方形 + [[nodiscard]] + constexpr RectF stretched(Arg::left_ left) const noexcept; + [[nodiscard]] constexpr RectF scaled(double s) const noexcept; diff --git a/Siv3D/include/Siv3D/detail/Rect.ipp b/Siv3D/include/Siv3D/detail/Rect.ipp index 53300fafb..6fd26a279 100644 --- a/Siv3D/include/Siv3D/detail/Rect.ipp +++ b/Siv3D/include/Siv3D/detail/Rect.ipp @@ -586,6 +586,26 @@ namespace s3d return{ (pos.x - left), (pos.y - top), (size.x + left + right), (size.y + top + bottom) }; } + inline constexpr Rect Rect::stretched(Arg::top_ top) const noexcept + { + return stretched(top.value(), 0, 0, 0); + } + + inline constexpr Rect Rect::stretched(Arg::right_ right) const noexcept + { + return stretched(0, right.value(), 0, 0); + } + + inline constexpr Rect Rect::stretched(Arg::bottom_ bottom) const noexcept + { + return stretched(0, 0, bottom.value(), 0); + } + + inline constexpr Rect Rect::stretched(Arg::left_ left) const noexcept + { + return stretched(0, 0, 0, left.value()); + } + inline constexpr RectF Rect::scaled(const double s) const noexcept { return{ Arg::center((pos.x + size.x * 0.5), (pos.y + size.y * 0.5)), (size.x * s), (size.y * s) }; diff --git a/Siv3D/include/Siv3D/detail/RectF.ipp b/Siv3D/include/Siv3D/detail/RectF.ipp index b28fbf295..93ea884e6 100644 --- a/Siv3D/include/Siv3D/detail/RectF.ipp +++ b/Siv3D/include/Siv3D/detail/RectF.ipp @@ -642,6 +642,26 @@ namespace s3d return{ (pos.x - left), (pos.y - top), (size.x + left + right), (size.y + top + bottom) }; } + inline constexpr RectF RectF::stretched(Arg::top_ top) const noexcept + { + return stretched(top.value(), 0, 0, 0); + } + + inline constexpr RectF RectF::stretched(Arg::right_ right) const noexcept + { + return stretched(0, right.value(), 0, 0); + } + + inline constexpr RectF RectF::stretched(Arg::bottom_ bottom) const noexcept + { + return stretched(0, 0, bottom.value(), 0); + } + + inline constexpr RectF RectF::stretched(Arg::left_ left) const noexcept + { + return stretched(0, 0, 0, left.value()); + } + inline constexpr RectF RectF::scaled(const double s) const noexcept { return{ Arg::center((pos.x + size.x * 0.5), (pos.y + size.y * 0.5)), (size.x * s), (size.y * s) };