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 {
37 {
38 public:
42 DOMMatrixReadOnly ( std::initializer_list<float> values = {1, 0, 0, 1, 0, 0} );
47 bool is2D() const;
50 bool isIdentity() const;
53 float a() const;
56 float b() const;
59 float c() const;
62 float d() const;
65 float e() const;
68 float f() const;
69
71 float m11() const;
73 float m12() const;
75 float m13() const;
77 float m14() const;
79 float m21() const;
81 float m22() const;
83 float m23() const;
85 float m24() const;
87 float m31() const;
89 float m32() const;
91 float m33() const;
93 float m34() const;
95 float m41() const;
97 float m42() const;
99 float m43() const;
101 float m44() const;
102
105 DOMMatrixReadOnly flipX() const;
108 DOMMatrixReadOnly flipY() const;
115 DOMMatrixReadOnly multiply ( const DOMMatrixReadOnly& other ) const;
123 DOMMatrixReadOnly rotateAxisAngle ( float x, float y, float z, float angle ) const;
130 DOMMatrixReadOnly rotate ( float rotX, float rotY, float rotZ ) const;
135 DOMMatrixReadOnly rotateFromVector ( float x, float y ) const;
144 DOMMatrixReadOnly scale ( float scaleX, float scaleY, float scaleZ, float originX, float originY, float originZ ) const;
151 DOMMatrixReadOnly scale3d ( float scale, float originX, float originY, float originZ ) const;
156 DOMMatrixReadOnly skewX ( float sx ) const;
161 DOMMatrixReadOnly skewY ( float sy ) const;
162
165 std::array<float, 16> toFloat32Array() const;
168 std::array<double, 16> toFloat64Array() const;
171 DOMString toJSON() const;
174 DOMString toString() const;
178 DOMPoint transformPoint ( const DOMPoint& point ) const;
184 DOMMatrixReadOnly translate ( float x, float y, float z ) const;
185
186 protected:
187 std::array<float, 16> mValues{};
188 bool mIs2D{};
189 };
190 }
191}
192
193#endif
Platform-specific DLL import/export macros and compiler helpers.
float m12() const
Get row 1, column 2.
Definition DOMMatrixReadOnly.cpp:104
DOMPoint transformPoint(const DOMPoint &point) const
Transform a point by this matrix.
Definition DOMMatrixReadOnly.cpp:447
float f() const
Get element f (alias m42 / translateY).
Definition DOMMatrixReadOnly.cpp:94
float m34() const
Get row 3, column 4.
Definition DOMMatrixReadOnly.cpp:144
float m14() const
Get row 1, column 4.
Definition DOMMatrixReadOnly.cpp:112
DOMMatrixReadOnly(std::initializer_list< float > values={1, 0, 0, 1, 0, 0})
Construct from an initializer list.
Definition DOMMatrixReadOnly.cpp:26
DOMMatrixReadOnly flipY() const
Flip around the Y axis.
Definition DOMMatrixReadOnly.cpp:175
DOMMatrixReadOnly rotateFromVector(float x, float y) const
Rotate from a direction vector.
Definition DOMMatrixReadOnly.cpp:333
DOMMatrixReadOnly rotateAxisAngle(float x, float y, float z, float angle) const
Rotate around an arbitrary axis.
Definition DOMMatrixReadOnly.cpp:254
DOMString toString() const
Serialize to a CSS matrix/matrix3d string.
Definition DOMMatrixReadOnly.cpp:426
float m41() const
Get row 4, column 1.
Definition DOMMatrixReadOnly.cpp:148
float a() const
Get element a (alias m11).
Definition DOMMatrixReadOnly.cpp:74
DOMMatrixReadOnly skewX(float sx) const
Skew along the X axis.
Definition DOMMatrixReadOnly.cpp:359
bool isIdentity() const
Check whether this is the identity matrix.
Definition DOMMatrixReadOnly.cpp:65
float d() const
Get element d (alias m22).
Definition DOMMatrixReadOnly.cpp:86
virtual ~DOMMatrixReadOnly()
Destructor.
float m13() const
Get row 1, column 3.
Definition DOMMatrixReadOnly.cpp:108
DOMString toJSON() const
Serialize to JSON.
Definition DOMMatrixReadOnly.cpp:392
DOMMatrixReadOnly flipX() const
Flip around the X axis.
Definition DOMMatrixReadOnly.cpp:165
float m32() const
Get row 3, column 2.
Definition DOMMatrixReadOnly.cpp:136
std::array< float, 16 > mValues
The 4x4 matrix values in column-major order.
Definition DOMMatrixReadOnly.hpp:187
float e() const
Get element e (alias m41 / translateX).
Definition DOMMatrixReadOnly.cpp:90
DOMMatrixReadOnly multiply(const DOMMatrixReadOnly &other) const
Post-multiply with another matrix.
Definition DOMMatrixReadOnly.cpp:226
DOMMatrixReadOnly scale(float scaleX, float scaleY, float scaleZ, float originX, float originY, float originZ) const
Scale with separate factors and origin.
Definition DOMMatrixReadOnly.cpp:339
float m43() const
Get row 4, column 3.
Definition DOMMatrixReadOnly.cpp:156
DOMMatrixReadOnly skewY(float sy) const
Skew along the Y axis.
Definition DOMMatrixReadOnly.cpp:368
float c() const
Get element c (alias m21).
Definition DOMMatrixReadOnly.cpp:82
bool is2D() const
Check whether this is a 2D matrix.
Definition DOMMatrixReadOnly.cpp:60
DOMMatrixReadOnly rotate(float rotX, float rotY, float rotZ) const
Rotate around each axis.
Definition DOMMatrixReadOnly.cpp:297
float m23() const
Get row 2, column 3.
Definition DOMMatrixReadOnly.cpp:124
float m21() const
Get row 2, column 1.
Definition DOMMatrixReadOnly.cpp:116
std::array< double, 16 > toFloat64Array() const
Return the matrix as a 16-element double array.
Definition DOMMatrixReadOnly.cpp:382
float m31() const
Get row 3, column 1.
Definition DOMMatrixReadOnly.cpp:132
DOMMatrixReadOnly translate(float x, float y, float z) const
Translate by (x, y, z).
Definition DOMMatrixReadOnly.cpp:457
float m33() const
Get row 3, column 3.
Definition DOMMatrixReadOnly.cpp:140
float m44() const
Get row 4, column 4.
Definition DOMMatrixReadOnly.cpp:160
float b() const
Get element b (alias m12).
Definition DOMMatrixReadOnly.cpp:78
bool mIs2D
Whether the matrix represents a 2D transform.
Definition DOMMatrixReadOnly.hpp:188
float m24() const
Get row 2, column 4.
Definition DOMMatrixReadOnly.cpp:128
float m42() const
Get row 4, column 2.
Definition DOMMatrixReadOnly.cpp:152
DOMMatrixReadOnly inverse() const
Compute the inverse.
Definition DOMMatrixReadOnly.cpp:185
DOMMatrixReadOnly scale3d(float scale, float originX, float originY, float originZ) const
Uniform 3D scale with origin.
Definition DOMMatrixReadOnly.cpp:354
std::array< float, 16 > toFloat32Array() const
Return the matrix as a 16-element float array.
Definition DOMMatrixReadOnly.cpp:377
float m22() const
Get row 2, column 2.
Definition DOMMatrixReadOnly.cpp:120
float m11() const
Get row 1, column 1.
Definition DOMMatrixReadOnly.cpp:100
Mutable 3D point with a perspective component.
Definition DOMPoint.hpp:32