diff options
author | MacDue <macdue@dueutil.tech> | 2022-10-01 22:38:06 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-10-02 21:17:41 +0200 |
commit | 3d532571bb3288eab8d903b0ed3c45aec87f5286 (patch) | |
tree | b2fe376cba43f613312f138ba32b46c1e6117a68 /Userland | |
parent | 95878688a7492aac177aa4076817459950f2b4d4 (diff) | |
download | serenity-3d532571bb3288eab8d903b0ed3c45aec87f5286.zip |
LibGfx: Add Matrix::operator*(T scalar)
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/Matrix.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Matrix.h b/Userland/Libraries/LibGfx/Matrix.h index 7931b3c92b..af7358c017 100644 --- a/Userland/Libraries/LibGfx/Matrix.h +++ b/Userland/Libraries/LibGfx/Matrix.h @@ -104,6 +104,21 @@ public: return division; } + friend constexpr Matrix operator*(Matrix const& matrix, T scalar) + { + Matrix scaled; + for (size_t i = 0; i < N; ++i) { + for (size_t j = 0; j < N; ++j) + scaled.m_elements[i][j] = matrix.m_elements[i][j] * scalar; + } + return scaled; + } + + friend constexpr Matrix operator*(T scalar, Matrix const& matrix) + { + return matrix * scalar; + } + [[nodiscard]] constexpr Matrix adjugate() const { if constexpr (N == 1) |