<body> <divid="container"></div> <buttonid="flip">Flip horizontally</button> <script> var width = window.innerWidth; var height = window.innerHeight;
var stage = new Konva.Stage({ container: 'container', width: width, height: height, });
var layer = new Konva.Layer(); stage.add(layer);
var text1 = new Konva.Text({ x: 180, y: 50, text: 'Default text with no offset. Its origin is in top left corner.', align: 'center', width: 200, }); layer.add(text1);
var text2 = new Konva.Text({ text: 'Text with the origin in its center', width: 200, align: 'center', y: 100, x: 270, }); layer.add(text2); // set horizontal origin in the center of the text text2.offsetX(text2.width() / 2);