Canvas Flip Image — Mirror and Flip Shapes on HTML5 Canvas
Flip any image or shape on an HTML5 Canvas — horizontally, vertically, or both. This technique is essential for building image editors, design tools, and canvas-based applications where users need to mirror content.
To flip any node with Konva you can use negative scaleX to flip it horizontally or scaleY to flip it vertically. The scale properties work relative to the origin of a node. For a rectangle that's the top-left corner; for a circle it's the center. You can change the origin with offsetX and offsetY — see the Position vs Offset guide for details.
Depending on your use case, you may need to adjust {x, y} to keep the node in its original position after flipping.
Instructions: click the flip buttons to see shapes mirror horizontally and vertically.
- Vanilla
- React
- Vue