mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:57:46 +00:00
LibWeb: Add DOMMatrix flipX and flipY
This commit is contained in:
parent
fc380bf516
commit
f1742ae1b9
5 changed files with 50 additions and 2 deletions
|
@ -284,6 +284,44 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> DOMMatrixReadOnly::multiply(DOM
|
|||
return result->multiply_self(other);
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-flipx
|
||||
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::flip_x()
|
||||
{
|
||||
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
|
||||
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
|
||||
|
||||
// 2. Post-multiply result with new DOMMatrix([-1, 0, 0, 1, 0, 0]).
|
||||
// clang-format off
|
||||
Gfx::DoubleMatrix4x4 flip_matrix = { -1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1 };
|
||||
// clang-format on
|
||||
result->m_matrix = result->m_matrix * flip_matrix;
|
||||
|
||||
// 3. Return result.
|
||||
return result;
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-flipy
|
||||
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::flip_y()
|
||||
{
|
||||
// 1. Let result be the resulting matrix initialized to the values of the current matrix.
|
||||
auto result = DOMMatrix::create_from_dom_matrix_read_only(realm(), *this);
|
||||
|
||||
// 2. Post-multiply result with new DOMMatrix([1, 0, 0, -1, 0, 0]).
|
||||
// clang-format off
|
||||
Gfx::DoubleMatrix4x4 flip_matrix = { 1, 0, 0, 0,
|
||||
0, -1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1 };
|
||||
// clang-format on
|
||||
result->m_matrix = result->m_matrix * flip_matrix;
|
||||
|
||||
// 3. Return result.
|
||||
return result;
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-inverse
|
||||
JS::NonnullGCPtr<DOMMatrix> DOMMatrixReadOnly::inverse() const
|
||||
{
|
||||
|
|
|
@ -88,6 +88,8 @@ public:
|
|||
JS::NonnullGCPtr<DOMMatrix> skew_x(double sx = 0) const;
|
||||
JS::NonnullGCPtr<DOMMatrix> skew_y(double sy = 0) const;
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMMatrix>> multiply(DOMMatrixInit other = {});
|
||||
JS::NonnullGCPtr<DOMMatrix> flip_x();
|
||||
JS::NonnullGCPtr<DOMMatrix> flip_y();
|
||||
JS::NonnullGCPtr<DOMMatrix> inverse() const;
|
||||
|
||||
JS::NonnullGCPtr<DOMPoint> transform_point(DOMPointInit const&) const;
|
||||
|
|
|
@ -49,8 +49,8 @@ interface DOMMatrixReadOnly {
|
|||
[NewObject] DOMMatrix skewX(optional unrestricted double sx = 0);
|
||||
[NewObject] DOMMatrix skewY(optional unrestricted double sy = 0);
|
||||
[NewObject] DOMMatrix multiply(optional DOMMatrixInit other = {});
|
||||
// FIXME: [NewObject] DOMMatrix flipX();
|
||||
// FIXME: [NewObject] DOMMatrix flipY();
|
||||
[NewObject] DOMMatrix flipX();
|
||||
[NewObject] DOMMatrix flipY();
|
||||
[NewObject] DOMMatrix inverse();
|
||||
|
||||
[NewObject] DOMPoint transformPoint(optional DOMPointInit point = {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue