فهرست منبع

LibGfx: Add Gfx::extract_2d_affine_transform(Matrix4x4) helper

MacDue 1 سال پیش
والد
کامیت
848b0d9c81
1فایلهای تغییر یافته به همراه8 افزوده شده و 0 حذف شده
  1. 8 0
      Userland/Libraries/LibGfx/Matrix4x4.h

+ 8 - 0
Userland/Libraries/LibGfx/Matrix4x4.h

@@ -7,6 +7,7 @@
 #pragma once
 
 #include <AK/Math.h>
+#include <LibGfx/AffineTransform.h>
 #include <LibGfx/Matrix.h>
 #include <LibGfx/Vector3.h>
 #include <LibGfx/Vector4.h>
@@ -76,6 +77,13 @@ constexpr static Matrix4x4<T> rotation_matrix(Vector3<T> const& axis, T angle)
         0, 0, 0, 1);
 }
 
+template<typename T>
+Gfx::AffineTransform extract_2d_affine_transform(Matrix4x4<T> const& matrix)
+{
+    auto* m = matrix.elements();
+    return Gfx::AffineTransform(m[0][0], m[1][0], m[0][1], m[1][1], m[0][3], m[1][3]);
+}
+
 typedef Matrix4x4<float> FloatMatrix4x4;
 typedef Matrix4x4<double> DoubleMatrix4x4;
 }