-
Notifications
You must be signed in to change notification settings - Fork 22.6k
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.flipY() #37171
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
36dad82
New page: DOMMatrixReadOnly.flipY()
estelle 12c098b
New page: DOMMatrixReadOnly.flipY()
estelle 3979c05
return value
estelle 8259ff8
Merge branch 'main' into flip
estelle 7fb16ea
Merge branch 'main' into flip
bsmth 6e72066
Update files/en-us/web/api/dommatrixreadonly/flipy/index.md
estelle e94428d
Update files/en-us/web/api/dommatrixreadonly/flipy/index.md
estelle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
title: "DOMMatrixReadOnly: flipY() method" | ||
short-title: flipY() | ||
slug: Web/API/DOMMatrixReadOnly/flipY | ||
page-type: web-api-instance-method | ||
browser-compat: api.DOMMatrixReadOnly.flipY | ||
--- | ||
|
||
{{APIRef("Geometry Interfaces")}}{{AvailableInWorkers}} | ||
|
||
The **`flipY()`** method of the {{domxref("DOMMatrixReadOnly")}} interface creates a new matrix being the result of the original matrix flipped about the y-axis. This is equivalent to multiplying the matrix by `DOMMatrix(1, 0, 0, -1, 0, 0)`. The original matrix is not modified. | ||
|
||
## Syntax | ||
|
||
```js-nolint | ||
DOMMatrixReadOnly.flipY() | ||
``` | ||
|
||
### Return value | ||
|
||
A [`DOMMatrix`](/en-US/docs/Web/API/DOMMatrix). | ||
|
||
## Examples | ||
|
||
### Inverting a triangle | ||
|
||
In this example, the SVG contains two identical [paths](/en-US/docs/Web/SVG/Attribute/d) in the shape of a triangle; they are both drawn to have the same size and position. The viewbox has a negative y value showing us content from both sides of the y-axis. This enables the flipped triangle to be withing the viewport after it is transformed. | ||
|
||
#### HTML | ||
|
||
```html | ||
<svg height="200" width="100" viewBox="0 -100 100 200"> | ||
<path fill="red" d="M 0 0 L 100 0 L 50 100 Z" /> | ||
<path fill="blue" d="M 0 0 L 100 0 L 50 100 Z" id="flipped" /> | ||
</svg> | ||
``` | ||
|
||
#### JavaScript | ||
|
||
The JavaScript creates an [identity matrix](/en-US/docs/Web/API/DOMMatrixReadOnly/isIdentity), then uses the `flipY()` method to create a new matrix, which is then applied to the blue triangle, inverting it across the y-axis. The red triangle is left in place. | ||
|
||
```js | ||
const flipped = document.getElementById("flipped"); | ||
const matrix = new DOMMatrix(); | ||
const flippedMatrix = matrix.flipY(); | ||
flipped.setAttribute("transform", flippedMatrix.toString()); | ||
``` | ||
|
||
#### Result | ||
|
||
{{EmbedLiveSample('Inverting a triangle')}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a big deal, but there's a vertical scrollbar here.
estelle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("DOMMatrixReadOnly.flipX()")}} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this doc coming soon? Currently broken link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's in another PR