Languages
[Edit]
EN

JavaScript - flip canvas horizontally

0 points
Created by:
Giles-Whittaker
739

In this article, we would like to show you how to flip canvas horizontally using JavaScript.

Quick solution:

Note:

The x-coordinates of all points inside the canvas are negative now.

 

Practical example

Edit

In this example, we use scale() method with negative x coordinate to flip the text on canvas horizontally.  

See also

Edit
  1. JavaScript - draw text on canvas

References

Edit
  1. CanvasRenderingContext2D.scale() - Web APIs | MDN
  2. CanvasRenderingContext2D.fillText() - Web APIs | MDN

Alternative titles

  1. JavaScript - canvas horizontal flip
  2. JavaScript - canvas horizontal mirror image
  3. JavaScript - flip canvas horizontally (x-axis)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join