fabricjs/fabric.js
qrDecompose.angle does not match obj.angle with flipX applied
Open
#5,079 opened on Jun 29, 2018
help wanted
Repository metrics
- Stars
- (31,387 stars)
- PR merge metrics
- (Avg merge 27d 13h) (10 merged PRs in 30d)
Description
Version
2.3.3
Test Case
Go to http://fabricjs.com/matrix-transformation and run this script in console:
var obj = __canvas.item(0);
function testObject() {
var transformValues = fabric.util.qrDecompose(obj.calcTransformMatrix());
var match = obj.angle === transformValues.angle;
console.log(match ? 'yes' : 'NO', obj.angle, transformValues);
}
testObject(); // obj.angle and matrix.angle match
obj.flipX = true;
__canvas.requestRenderAll();
setTimeout(testObject, 100); // obj.angle correctly zero. matrix.angle is now 180
Steps to reproduce
Run the script above or:
- add an object to canvas. obj.angle will be zero. calcTransformMatrix + qrDecompose angle will be zero
- obj.flipX = true; requestRenderAll()
- obj.angle remains zero. qrDecompose now returns 180
Expected Behavior
fabric.util.qrDecompose(obj.calcTransformMatrix()).angle and obj.angle should both equal zero, or qrDecompose shouldn't return an angle property if it can't return an accurate value.
Actual Behavior
After the flip is applied, the result from qrDecompose is 180.
If qrDecompose can't be used this way, what is the recommended way to get the ungrouped object properties from a selection's object:modified event?