diff options
author | MacDue <macdue@dueutil.tech> | 2023-04-09 18:31:00 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-12 07:40:22 +0200 |
commit | b8d1fae31f080391ccb0cc3f2992af51e8a38f73 (patch) | |
tree | 23d0c4ee45fa2c24a31560657a0a5f8d58564ef7 | |
parent | 790daa475478aaf77bd064ddfa23f61529d1ef29 (diff) | |
download | serenity-b8d1fae31f080391ccb0cc3f2992af51e8a38f73.zip |
LibGfx: Add AffineTransform::skew_radians()
-rw-r--r-- | Userland/Libraries/LibGfx/AffineTransform.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/AffineTransform.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/AffineTransform.cpp b/Userland/Libraries/LibGfx/AffineTransform.cpp index 8f7ba57452..4e4fbaef4b 100644 --- a/Userland/Libraries/LibGfx/AffineTransform.cpp +++ b/Userland/Libraries/LibGfx/AffineTransform.cpp @@ -79,6 +79,13 @@ AffineTransform& AffineTransform::set_scale(FloatPoint s) return set_scale(s.x(), s.y()); } +AffineTransform& AffineTransform::skew_radians(float x_radians, float y_radians) +{ + AffineTransform skew_transform(1, AK::tan(y_radians), AK::tan(x_radians), 1, 0, 0); + multiply(skew_transform); + return *this; +} + AffineTransform& AffineTransform::translate(float tx, float ty) { m_values[4] += tx * m_values[0] + ty * m_values[2]; diff --git a/Userland/Libraries/LibGfx/AffineTransform.h b/Userland/Libraries/LibGfx/AffineTransform.h index bab97bf63c..45555eec21 100644 --- a/Userland/Libraries/LibGfx/AffineTransform.h +++ b/Userland/Libraries/LibGfx/AffineTransform.h @@ -64,6 +64,7 @@ public: AffineTransform& set_translation(float tx, float ty); AffineTransform& set_translation(FloatPoint t); AffineTransform& rotate_radians(float); + AffineTransform& skew_radians(float x_radians, float y_radians); AffineTransform& multiply(AffineTransform const&); Optional<AffineTransform> inverse() const; |