The demo shows the result of applying transformMatrix to a Fabric object. For more on transformMatrix, see this excellent tutorial.
transformMatrix == [
1,
0,
0,
1,
0,
0
]
mergedProperties:
ScaleX: 1,
ScaleY: 1,
SkewX: 0,
SkewY: 0,
top: 0,
left: 0,
flipX: 0,
flipY: 0,
angle: 0
var obj = canvas.item(0);
// get the current transform matrix, from object properties.
var currentT = obj.calcTransformMatrix();
// get the transformMatrix array
var transformMatrix = obj.transformMatrix;
// multiply the matrices together to get the combined transform
var mT = fabric.util.multiplyTransformMatrices(currentT, transformMatrix);
// Unfold the matrix in a combination of scaleX, scaleY, skewX, skewY...
var options = fabric.util.qrDecompose(mT);
var newCenter = { x: options.translateX, y: options.translateY };
// reset transformMatrix to identity and resets flips since negative scale
// resulting from decompose, will automatically set them.
obj.transformMatrix = [ 1,0,0,1,0,0];
obj.flipX = false;
obj.flipY = false;
obj.set(options);
// position the object in the center given from translateX and translateY
obj.setPositionByOrigin(newCenter, 'center', 'center');