diff --git a/Userland/Libraries/LibGfx/AffineTransform.cpp b/Userland/Libraries/LibGfx/AffineTransform.cpp index 4e4fbaef4b..31da63b65b 100644 --- a/Userland/Libraries/LibGfx/AffineTransform.cpp +++ b/Userland/Libraries/LibGfx/AffineTransform.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -229,4 +230,14 @@ Quad AffineTransform::map_to_quad(Rect const& rect) const }; } +float AffineTransform::rotation() const +{ + auto rotation = AK::atan2(b(), a()); + while (rotation < -AK::Pi) + rotation += 2.0f * AK::Pi; + while (rotation > AK::Pi) + rotation -= 2.0f * AK::Pi; + return rotation; +} + } diff --git a/Userland/Libraries/LibGfx/AffineTransform.h b/Userland/Libraries/LibGfx/AffineTransform.h index 45555eec21..beebcdc855 100644 --- a/Userland/Libraries/LibGfx/AffineTransform.h +++ b/Userland/Libraries/LibGfx/AffineTransform.h @@ -54,6 +54,7 @@ public: [[nodiscard]] float x_translation() const; [[nodiscard]] float y_translation() const; [[nodiscard]] FloatPoint translation() const; + [[nodiscard]] float rotation() const; AffineTransform& scale(float sx, float sy); AffineTransform& scale(FloatPoint s);