问题
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();
});
回答1:
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();
});
回答2:
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();
}
}
来源:https://stackoverflow.com/questions/18482997/fabric-js-to-show-mirror-image-of-canvas-text