mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix item global matrix error (#1562)
Bug happen when item is drawn after an empty symbol that should be drawn in a separate canvas context (partial opacity or special blend mode). As bounds are empty, symbol drawing process is interrupted but its global matrix is not removed from the stack. Closes #1561
This commit is contained in:
parent
5245436e36
commit
5cd1ca13c5
2 changed files with 14 additions and 1 deletions
|
@ -4327,8 +4327,12 @@ new function() { // Injection scope for hit-test functions shared with project
|
|||
// Apply the parent's global matrix to the calculation of correct
|
||||
// bounds.
|
||||
var bounds = this.getStrokeBounds(viewMatrix);
|
||||
if (!bounds.width || !bounds.height)
|
||||
if (!bounds.width || !bounds.height) {
|
||||
// Item won't be drawn so its global matrix need to be removed
|
||||
// from the stack (#1561).
|
||||
matrices.pop();
|
||||
return;
|
||||
}
|
||||
// Store previous offset and save the main context, so we can
|
||||
// draw onto it later.
|
||||
prevOffset = param.offset;
|
||||
|
|
|
@ -789,3 +789,12 @@ test('group.internalBounds with child and child.applyMatrix = false (#1250)', fu
|
|||
equals(group.internalBounds, new Rectangle(0, 0, 250, 250),
|
||||
'group.internalBounds after scaling item1');
|
||||
});
|
||||
|
||||
test('#1561 item._globalMatrix on item after empty symbol', function(){
|
||||
var symbol = new SymbolItem(new Path());
|
||||
symbol.opacity = 0.5;
|
||||
symbol.skew(10);
|
||||
var item = new Path.Circle(new Point(0,0), 10);
|
||||
view.update();
|
||||
equals(item._globalMatrix, new Matrix());
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue