LibGfx: Implement AffineTransform::to_matrix()

This commit is contained in:
Aliaksandr Kalenik 2025-10-09 00:01:27 +02:00 committed by Alexander Kalenik
parent c630de17ab
commit 7ba34e8bd1
2 changed files with 13 additions and 0 deletions

View File

@ -248,4 +248,14 @@ float AffineTransform::rotation() const
return rotation; return rotation;
} }
Matrix<4, float> AffineTransform::to_matrix() const
{
return {
a(), c(), 0.f, e(),
b(), d(), 0.f, f(),
0.f, 0.f, 1.f, 0.f,
0.f, 0.f, 0.f, 1.f
};
}
} }

View File

@ -10,6 +10,7 @@
#include <AK/Format.h> #include <AK/Format.h>
#include <AK/Forward.h> #include <AK/Forward.h>
#include <LibGfx/Forward.h> #include <LibGfx/Forward.h>
#include <LibGfx/Matrix.h>
namespace Gfx { namespace Gfx {
@ -83,6 +84,8 @@ public:
float determinant() const; float determinant() const;
Optional<AffineTransform> inverse() const; Optional<AffineTransform> inverse() const;
Matrix<4, float> to_matrix() const;
private: private:
float m_values[6] { 0 }; float m_values[6] { 0 };
}; };