mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
BlendMode: support DocumentView and return if an item's bounds is null.
This commit is contained in:
parent
0e011dee2a
commit
eee5e63a72
1 changed files with 6 additions and 2 deletions
|
@ -30,15 +30,18 @@ BlendMode = {
|
||||||
process: function(documentContext, item, param) {
|
process: function(documentContext, item, param) {
|
||||||
// TODO: use strokeBounds
|
// TODO: use strokeBounds
|
||||||
var itemBounds = item.bounds;
|
var itemBounds = item.bounds;
|
||||||
|
if (!itemBounds)
|
||||||
|
return;
|
||||||
var top = Math.floor(itemBounds.top);
|
var top = Math.floor(itemBounds.top);
|
||||||
var left = Math.floor(itemBounds.left);
|
var left = Math.floor(itemBounds.left);
|
||||||
var size = itemBounds.size.ceil();
|
var size = itemBounds.size.ceil().add(1, 1);
|
||||||
var width = size.width;
|
var width = size.width;
|
||||||
var height = size.height;
|
var height = size.height;
|
||||||
|
|
||||||
var itemCanvas = CanvasProvider.getCanvas(size);
|
var itemCanvas = CanvasProvider.getCanvas(size);
|
||||||
var itemContext = itemCanvas.getContext('2d');
|
var itemContext = itemCanvas.getContext('2d');
|
||||||
if(item.matrix) {
|
itemContext.save();
|
||||||
|
if (item.matrix) {
|
||||||
var matrix = item.matrix.clone();
|
var matrix = item.matrix.clone();
|
||||||
var transMatrix = Matrix.getTranslateInstance(-left, -top);
|
var transMatrix = Matrix.getTranslateInstance(-left, -top);
|
||||||
matrix.preConcatenate(transMatrix);
|
matrix.preConcatenate(transMatrix);
|
||||||
|
@ -210,6 +213,7 @@ BlendMode = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
documentContext.putImageData(dstD, left, top);
|
documentContext.putImageData(dstD, left, top);
|
||||||
|
itemContext.restore();
|
||||||
CanvasProvider.returnCanvas(itemCanvas);
|
CanvasProvider.returnCanvas(itemCanvas);
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Reference in a new issue