Skip to content

Commit

Permalink
New page: DOMMatrixReadOnly.is2d (#37169)
Browse files Browse the repository at this point in the history
* New page: dommatrixreadonly.is2d

* New page: dommatrixreadonly.is2d

* isidentity

* typo

* remove properties that are not in the object

* remove properties that are not in the object

* Edits per review

---------

Co-authored-by: Brian Smith <[email protected]>
  • Loading branch information
estelle and bsmth authored Jan 23, 2025
1 parent 94b32d9 commit c783eb1
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 8 deletions.
7 changes: 2 additions & 5 deletions files/en-us/web/api/dommatrix/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ The interface is available inside [web workers](/en-US/docs/Web/API/Web_Workers_

_This interface inherits properties from {{domxref("DOMMatrixReadOnly")}}, though some of these properties are altered to be mutable._

- `is2D` {{ReadOnlyInline}}
- : A Boolean flag whose value is `true` if the matrix was initialized as a 2D matrix. If `false`, the matrix is 3D.
- `isIdentity` {{ReadOnlyInline}}
- : A Boolean whose value is `true` if the matrix is the [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix). The identity matrix is one in which every value is `0` _except_ those on the main diagonal from top-left to bottom-right corner (in other words, where the offsets in each direction are equal).
- `m11`, `m12`, `m13`, `m14`, `m21`, `m22`, `m23`, `m24`, `m31`, `m32`, `m33`, `m34`, `m41`, `m42`, `m43`, `m44`
- : Double-precision floating-point values representing each component of a 4×4 matrix, where `m11` through `m14` are the first column, `m21` through `m24` are the second column, and so forth.
- `a`, `b`, `c`, `d`, `e`, `f`
Expand Down Expand Up @@ -106,4 +102,5 @@ The `DOMMatrix` interface is designed with the intent that it will be used for a

## See also

- Its non-modifiable counterpart, {{domxref("DOMMatrixReadOnly")}}
- {{domxref("DOMMatrixReadOnly.is2D")}}
- {{domxref("DOMMatrixReadOnly.isIdentity")}}
6 changes: 3 additions & 3 deletions files/en-us/web/api/dommatrixreadonly/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ This interface should be available inside [web workers](/en-US/docs/Web/API/Web_

_This interface doesn't inherit any properties._

- `is2D` {{ReadOnlyInline}}
- {{domxref("DOMMatrixReadOnly.is2D")}} {{ReadOnlyInline}}
- : A Boolean flag whose value is `true` if the matrix was initialized as a 2D matrix. If `false`, the matrix is 3D.
- `isIdentity` {{ReadOnlyInline}}
- : A Boolean whose value is `true` if the matrix is the [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix). The identity matrix is one in which every value is `0` _except_ those on the main diagonal from top-left to bottom-right corner (in other words, where the offsets in each direction are equal).
- {{domxref("DOMMatrixReadOnly.isIdentity")}} {{ReadOnlyInline}}
- : A Boolean whose value is `true` if the matrix is an [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix).
- `m11`, `m12`, `m13`, `m14`, `m21`, `m22`, `m23`, `m24`, `m31`, `m32`, `m33`, `m34`, `m41`, `m42`, `m43`, `m44`
- : Double-precision floating-point values representing each component of a 4×4 matrix, where `m11` through `m14` are the first column, `m21` through `m24` are the second column, and so forth.
- `a`, `b`, `c`, `d`, `e`, `f`
Expand Down
47 changes: 47 additions & 0 deletions files/en-us/web/api/dommatrixreadonly/is2d/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: "DOMMatrixReadOnly: is2D property"
short-title: is2D
slug: Web/API/DOMMatrixReadOnly/is2D
page-type: web-api-instance-method
browser-compat: api.DOMMatrixReadOnly.is2D
---

{{APIRef("Geometry Interfaces")}}{{AvailableInWorkers}}

The readonly **`is2D`** property of the {{domxref("DOMMatrixReadOnly")}} interface is a Boolean flag that is `true` when the matrix is 2D. The value is `true` if the matrix was initialized as a 2D matrix and only 2D transformation operations were applied. Otherwise, the matrix is defined in 3D, and `is2D` is `false`.

## Value

A Boolean value.

## Examples

```js
// Initialize a 2D matrix
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.is2D); // output: true

// Transform in a 2D space
console.log(matrix.rotate(30).is2D); // output: true

// Apply a 3D transform
console.log(matrix.rotate(10, 20, 1).is2D); // output: false
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("CSSTransformValue.is2D")}}
- {{domxref("CSSTransformComponent.is2D")}}
- CSS {{cssxref("transform-function")}} functions
- CSS {{cssxref("transform")}} property
- [CSS transforms](/en-US/docs/Web/CSS/CSS_transforms) module
- SVG [`transform`](/en-US/docs/Web/SVG/Attribute/transform) attribute
- {{domxref("CanvasRenderingContext2D")}} interface
49 changes: 49 additions & 0 deletions files/en-us/web/api/dommatrixreadonly/isidentity/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: "DOMMatrixReadOnly: isIdentity property"
short-title: isIdentity
slug: Web/API/DOMMatrixReadOnly/isIdentity
page-type: web-api-instance-method
browser-compat: api.DOMMatrixReadOnly.isIdentity
---

{{APIRef("Geometry Interfaces")}}{{AvailableInWorkers}}

The readonly **`isIdentity`** property of the {{domxref("DOMMatrixReadOnly")}} interface is a Boolean whose value is `true` if the matrix is the [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix).

The identity matrix is one in which every value is `0` _except_ those on the main diagonal from top-left to bottom-right corner (in other words, where the offsets in each direction are equal).

## Value

A Boolean value.

## Examples

```js
// Initialize a 2D matrix
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.isIdentity); // output: true

// Apply a transform that has no effect
console.log(matrix.translate(0).isIdentity); // output: true

// Apply a transform with effect: this rotates the matrix by 30deg
console.log(matrix.rotate(30).isIdentity); // output: false
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("DOMMatrix")}} interface
- {{domxref("CSSMatrixComponent")}} interface
- {{domxref("CanvasRenderingContext2D")}} interface
- CSS {{cssxref("transform-function/matrix()")}} function
- CSS {{cssxref("transform")}} property
- [CSS transforms](/en-US/docs/Web/CSS/CSS_transforms) module
- SVG [`transform`](/en-US/docs/Web/SVG/Attribute/transform) attribute

0 comments on commit c783eb1

Please sign in to comment.