AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
DOMMatrixReadOnly.hpp
1/*
2Copyright (C) 2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_DOMMATRIXREADONLY_HPP
17#define AEONGUI_DOMMATRIXREADONLY_HPP
18
19#include <initializer_list>
20#include <array>
21#include "aeongui/Platform.hpp"
22#include "DOMString.hpp"
23#include "DOMPoint.hpp"
24
25namespace AeonGUI
26{
27 namespace DOM
28 {
38 {
39 public:
43 DOMMatrixReadOnly ( std::initializer_list<float> values = {1, 0, 0, 1, 0, 0} );
48 bool is2D() const;
51 bool isIdentity() const;
54 float a() const;
57 float b() const;
60 float c() const;
63 float d() const;
66 float e() const;
69 float f() const;
70
72 float m11() const;
74 float m12() const;
76 float m13() const;
78 float m14() const;
80 float m21() const;
82 float m22() const;
84 float m23() const;
86 float m24() const;
88 float m31() const;
90 float m32() const;
92 float m33() const;
94 float m34() const;
96 float m41() const;
98 float m42() const;
100 float m43() const;
102 float m44() const;
103
106 DOMMatrixReadOnly flipX() const;
109 DOMMatrixReadOnly flipY() const;
116 DOMMatrixReadOnly multiply ( const DOMMatrixReadOnly& other ) const;
124 DOMMatrixReadOnly rotateAxisAngle ( float x, float y, float z, float angle ) const;
131 DOMMatrixReadOnly rotate ( float rotX, float rotY, float rotZ ) const;
136 DOMMatrixReadOnly rotateFromVector ( float x, float y ) const;
145 DOMMatrixReadOnly scale ( float scaleX, float scaleY, float scaleZ, float originX, float originY, float originZ ) const;
152 DOMMatrixReadOnly scale3d ( float scale, float originX, float originY, float originZ ) const;
157 DOMMatrixReadOnly skewX ( float sx ) const;
162 DOMMatrixReadOnly skewY ( float sy ) const;
163
166 std::array<float, 16> toFloat32Array() const;
169 std::array<double, 16> toFloat64Array() const;
172 DOMString toJSON() const;
175 DOMString toString() const;
179 DOMPoint transformPoint ( const DOMPoint& point ) const;
185 DOMMatrixReadOnly translate ( float x, float y, float z ) const;
186
187 protected:
188 std::array<float, 16> mValues{};
189 bool mIs2D{};
190 };
191 }
192}
193
194#endif
Platform-specific DLL import/export macros and compiler helpers.
float m12() const
Get row 1, column 2.
Definition DOMMatrixReadOnly.cpp:101
DOMPoint transformPoint(const DOMPoint &point) const
Transform a point by this matrix.
Definition DOMMatrixReadOnly.cpp:443
float f() const
Get element f (alias m42 / translateY).
Definition DOMMatrixReadOnly.cpp:91
float m34() const
Get row 3, column 4.
Definition DOMMatrixReadOnly.cpp:141
float m14() const
Get row 1, column 4.
Definition DOMMatrixReadOnly.cpp:109
DOMMatrixReadOnly(std::initializer_list< float > values={1, 0, 0, 1, 0, 0})
Construct from an initializer list.
Definition DOMMatrixReadOnly.cpp:24
DOMMatrixReadOnly flipY() const
Flip around the Y axis.
Definition DOMMatrixReadOnly.cpp:172
DOMMatrixReadOnly rotateFromVector(float x, float y) const
Rotate from a direction vector.
Definition DOMMatrixReadOnly.cpp:329
DOMMatrixReadOnly rotateAxisAngle(float x, float y, float z, float angle) const
Rotate around an arbitrary axis.
Definition DOMMatrixReadOnly.cpp:250
DOMString toString() const
Serialize to a CSS matrix/matrix3d string.
Definition DOMMatrixReadOnly.cpp:422
float m41() const
Get row 4, column 1.
Definition DOMMatrixReadOnly.cpp:145
float a() const
Get element a (alias m11).
Definition DOMMatrixReadOnly.cpp:71
DOMMatrixReadOnly skewX(float sx) const
Skew along the X axis.
Definition DOMMatrixReadOnly.cpp:355
bool isIdentity() const
Check whether this is the identity matrix.
Definition DOMMatrixReadOnly.cpp:62
float d() const
Get element d (alias m22).
Definition DOMMatrixReadOnly.cpp:83
virtual ~DOMMatrixReadOnly()
Destructor.
float m13() const
Get row 1, column 3.
Definition DOMMatrixReadOnly.cpp:105
DOMString toJSON() const
Serialize to JSON.
Definition DOMMatrixReadOnly.cpp:388
DOMMatrixReadOnly flipX() const
Flip around the X axis.
Definition DOMMatrixReadOnly.cpp:162
float m32() const
Get row 3, column 2.
Definition DOMMatrixReadOnly.cpp:133
std::array< float, 16 > mValues
The 4x4 matrix values in column-major order.
Definition DOMMatrixReadOnly.hpp:188
float e() const
Get element e (alias m41 / translateX).
Definition DOMMatrixReadOnly.cpp:87
DOMMatrixReadOnly multiply(const DOMMatrixReadOnly &other) const
Post-multiply with another matrix.
Definition DOMMatrixReadOnly.cpp:222
DOMMatrixReadOnly scale(float scaleX, float scaleY, float scaleZ, float originX, float originY, float originZ) const
Scale with separate factors and origin.
Definition DOMMatrixReadOnly.cpp:335
float m43() const
Get row 4, column 3.
Definition DOMMatrixReadOnly.cpp:153
DOMMatrixReadOnly skewY(float sy) const
Skew along the Y axis.
Definition DOMMatrixReadOnly.cpp:364
float c() const
Get element c (alias m21).
Definition DOMMatrixReadOnly.cpp:79
bool is2D() const
Check whether this is a 2D matrix.
Definition DOMMatrixReadOnly.cpp:57
DOMMatrixReadOnly rotate(float rotX, float rotY, float rotZ) const
Rotate around each axis.
Definition DOMMatrixReadOnly.cpp:293
float m23() const
Get row 2, column 3.
Definition DOMMatrixReadOnly.cpp:121
float m21() const
Get row 2, column 1.
Definition DOMMatrixReadOnly.cpp:113
std::array< double, 16 > toFloat64Array() const
Return the matrix as a 16-element double array.
Definition DOMMatrixReadOnly.cpp:378
float m31() const
Get row 3, column 1.
Definition DOMMatrixReadOnly.cpp:129
DOMMatrixReadOnly translate(float x, float y, float z) const
Translate by (x, y, z).
Definition DOMMatrixReadOnly.cpp:453
float m33() const
Get row 3, column 3.
Definition DOMMatrixReadOnly.cpp:137
float m44() const
Get row 4, column 4.
Definition DOMMatrixReadOnly.cpp:157
float b() const
Get element b (alias m12).
Definition DOMMatrixReadOnly.cpp:75
bool mIs2D
Whether the matrix represents a 2D transform.
Definition DOMMatrixReadOnly.hpp:189
float m24() const
Get row 2, column 4.
Definition DOMMatrixReadOnly.cpp:125
float m42() const
Get row 4, column 2.
Definition DOMMatrixReadOnly.cpp:149
DOMMatrixReadOnly inverse() const
Compute the inverse.
Definition DOMMatrixReadOnly.cpp:182
DOMMatrixReadOnly scale3d(float scale, float originX, float originY, float originZ) const
Uniform 3D scale with origin.
Definition DOMMatrixReadOnly.cpp:350
std::array< float, 16 > toFloat32Array() const
Return the matrix as a 16-element float array.
Definition DOMMatrixReadOnly.cpp:373
float m22() const
Get row 2, column 2.
Definition DOMMatrixReadOnly.cpp:117
float m11() const
Get row 1, column 1.
Definition DOMMatrixReadOnly.cpp:97
Mutable 3D point with a perspective component.
Definition DOMPoint.hpp:32