fabric.js to show mirror image of canvas text

2019-05-27 09:38发布

i am using fabric.js to write text on canva .later on click of button i want to show mirror image of text . is there any property in fabric.js which i can use to rotate text on canvas.

Please check , http://jsfiddle.net/BTh6A/9/

document.getElementById( 'btn' ).addEventListener( 'click', function (e) {
    var obj = canvas.getActiveObject();

    if ( !obj ) return;

    //here comes code to show mirror image

    obj.set( 'fill', '#FF0000' );
    canvas.renderAll();
});

2条回答
萌系小妹纸
2楼-- · 2019-05-27 09:55

Try this piece of code...I have edited it..

document.getElementById('btn').addEventListener('click', function (e) {

    canvas.getActiveObject().set("angle", "-180").set('flipY', true);
    canvas.renderAll();

});
查看更多
做个烂人
3楼-- · 2019-05-27 09:59
function flipX() {
    var obj = canvas.getActiveObject();
    if (obj) {
        obj.set('flipX', !obj.flipX);
        canvas.renderAll();
    }
}

function flipY() {
    var obj = canvas.getActiveObject();
    if (obj) {
        obj.set('flipY', !obj.flipY);
        canvas.renderAll();
    }
}
查看更多
登录 后发表回答