Skip to content

Commit

Permalink
prettify matrix3d
Browse files Browse the repository at this point in the history
  • Loading branch information
estelle authored Jan 29, 2025
1 parent 19e6c2e commit f29060c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
12 changes: 10 additions & 2 deletions files/en-us/web/api/dommatrix/rotateaxisangleself/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@ A [`DOMMatrix`](/en-US/docs/Web/API/DOMMatrix).
```js
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.rotateAxisAngleSelf(10, 20, 30, 45).toString());
// "matrix3d(0.728, 0.609, -0.315, 0, -0.525, 0.791, 0.315, 0, 0.441, -0.063, 0.895, 0, 0, 0, 0, 1)"
/* "matrix3d(
0.728, 0.609, -0.315, 0,
-0.525, 0.791, 0.315, 0,
0.441, -0.063, 0.895,
0, 0, 0, 0, 1)" */
console.log(matrix.toString());
// "matrix3d(0.728, 0.609, -0.315, 0, -0.525, 0.791, 0.315, 0, 0.441, -0.063, 0.895, 0, 0, 0, 0, 1)"
/* "matrix3d(
0.728, 0.609, -0.315, 0,
-0.525, 0.791, 0.315, 0,
0.441, -0.063, 0.895, 0,
0, 0, 0, 1)" */
```

## Specifications
Expand Down
18 changes: 15 additions & 3 deletions files/en-us/web/api/dommatrix/scale3dself/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,23 @@ Returns itself; a {{domxref("DOMMatrix")}}.
```js
const matrix = new DOMMatrix();
console.log(matrix.scale3dSelf(2).toString());
// matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)
/* matrix3d(
2, 0, 0, 0,
0, 2, 0, 0,
0, 0, 2, 0,
0, 0, 0, 1) */
console.log(matrix.scale3dSelf(3.1, 25, 25, 1.25).toString());
// matrix3d(6.2, 0, 0, 0, 0, 6.2, 0, 0, 0, 0, 6.2, 0, -105, -105, -5.25, 1)
/* matrix3d(
6.2, 0, 0, 0,
0, 6.2, 0, 0,
0, 0, 6.2, 0,
-105, -105, -5.25, 1) */
console.log(matrix.toString());
// matrix3d(6.2, 0, 0, 0, 0, 6.2, 0, 0, 0, 0, 6.2, 0, -105, -105, -5.25, 1) (same as above)
/* matrix3d(
6.2, 0, 0, 0,
0, 6.2, 0, 0,
0, 0, 6.2, 0,
-105, -105, -5.25, 1) (same as above) */
```

## Specifications
Expand Down
14 changes: 12 additions & 2 deletions files/en-us/web/api/dommatrixreadonly/rotateaxisangle/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,18 @@ A [`DOMMatrix`](/en-US/docs/Web/API/DOMMatrix).
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.rotateAxisAngle().toString()); // matrix(1, 0, 0, 1, 0, 0)
console.log(matrix.rotateAxisAngle(10, 20, 30).toString()); // matrix(1, 0, 0, 1, 0, 0)
console.log(matrix.rotateAxisAngle(10, 20, 30, 45).toString()); // matrix3d(0.728, 0.609, -0.315, 0, -0.525, 0.791, 0.315, 0, 0.441, -0.063, 0.895, 0, 0, 0, 0, 1)
console.log(matrix.rotateAxisAngle(5, 5, 5, -45).toString()); // matrix3d(0.805, -0.311, 0.506, 0, 0.506, 0.805, -0.311, 0, -0.311, 0.506, 0.805, 0, 0, 0, 0, 1)
console.log(matrix.rotateAxisAngle(10, 20, 30, 45).toString());
/* matrix3d(
0.728, 0.609, -0.315, 0,
-0.525, 0.791, 0.315, 0,
0.441, -0.063, 0.895,
0, 0, 0, 0, 1) */
console.log(matrix.rotateAxisAngle(5, 5, 5, -45).toString());
/* matrix3d(
0.805, -0.311, 0.506, 0,
0.506, 0.805, -0.311, 0,
-0.311, 0.506, 0.805, 0,
0, 0, 0, 1) */
console.log(matrix.toString()); // output: "matrix(1, 0, 0, 1, 0, 0)" (unchanged)
```

Expand Down
12 changes: 10 additions & 2 deletions files/en-us/web/api/dommatrixreadonly/scale3d/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ console.log(matrix.toString()); // no transforms applied
// matrix(1, 0, 0, 1, 0, 0)

console.log(matrix.scale3d(2).toString());
// matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)
/* matrix3d(
2, 0, 0, 0,
0, 2, 0, 0,
0, 0, 2, 0,
0, 0, 0, 1) */
console.log(matrix.scale3d(0.5, 25, 25, 1.25).toString());
// matrix3d(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 12.5, 12.5, 0.625, 1)
/* matrix3d(
0.5, 0, 0, 0,
0, 0.5, 0, 0,
0, 0, 0.5, 0, 1
2.5, 12.5, 0.625, 1) */
console.log(matrix.toString()); // original matrix is unchanged
// matrix(1, 0, 0, 1, 0, 0)
```
Expand Down

0 comments on commit f29060c

Please sign in to comment.