Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New page: DOMMatrixReadOnly.is2d #37169

Merged
merged 10 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
51 changes: 51 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,51 @@
---
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`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean or boolean? We use "boolean" down in Value.


## Syntax
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


```js-nolint
DOMMatrixReadOnly.is2D
```

## 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
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mad picky comment, but I think it's more readable with whitespace:

Suggested change
```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
```
```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

Optional, but if you do it here do it for the other page too.


## 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
53 changes: 53 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,53 @@
---
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).

## Syntax
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


```js-nolint
DOMMatrixReadOnly.isIdentity
```

## 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
Loading