fabricjs/fabric.js

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

オープン

#5,079 opened on 2018/06/29

 (8 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (3,620 件のフォーク)batch import
help wanted

Repository metrics

Stars
 (31,401 個のスター)
PR merge metrics
 (平均マージ 27d 13h) (30d で 10 merged PRs)

説明

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?

コントリビューターガイド