-
Notifications
You must be signed in to change notification settings - Fork 22.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New page: DOMMatrixReadOnly.is2d (#37169)
* 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
Showing
4 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |