fabricjs/fabric.js

qrDecompose.angle does not match obj.angle with flipX applied

Aperta

#5079 aperta il 29 giu 2018

 (8 commenti) (0 reazioni) (0 assegnatari)TypeScript (3620 fork)batch import
help wanted

Metriche repository

Star
 (31.401 stelle)
Metriche merge PR
 (Merge medio 27g 13h) (10 PR mergiate in 30 g)

Descrizione

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:

  1. add an object to canvas. obj.angle will be zero. calcTransformMatrix + qrDecompose angle will be zero
  2. obj.flipX = true; requestRenderAll()
  3. 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?

Guida contributor