diff options
Diffstat (limited to 'Userland/Libraries/LibGfx/Matrix.h')
-rw-r--r-- | Userland/Libraries/LibGfx/Matrix.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Matrix.h b/Userland/Libraries/LibGfx/Matrix.h index 2e251de293..78be55f48f 100644 --- a/Userland/Libraries/LibGfx/Matrix.h +++ b/Userland/Libraries/LibGfx/Matrix.h @@ -13,6 +13,9 @@ namespace Gfx { template<size_t N, typename T> class Matrix { + template<size_t U, typename V> + friend class Matrix; + public: static constexpr size_t Size = N; @@ -173,6 +176,17 @@ public: return result; } + template<size_t U> + [[nodiscard]] constexpr Matrix<U, T> submatrix_from_topleft() const requires(U > 0 && U < N) + { + Matrix<U, T> result; + for (size_t i = 0; i < U; ++i) { + for (size_t j = 0; j < U; ++j) + result.m_elements[i][j] = m_elements[i][j]; + } + return result; + } + private: T m_elements[N][N]; }; |