mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Group: fix clipping. Fixes #66
This commit is contained in:
parent
c339ffca35
commit
2fff5b4f79
2 changed files with 8 additions and 3 deletions
|
@ -120,8 +120,11 @@ var Group = this.Group = Item.extend(/** @lends Group# */{
|
|||
|
||||
draw: function(ctx, param) {
|
||||
var clipItem = this._getClipItem();
|
||||
if (clipItem)
|
||||
if (clipItem) {
|
||||
param.clipping = true;
|
||||
Item.draw(clipItem, ctx, param);
|
||||
delete param.clipping;
|
||||
}
|
||||
for (var i = 0, l = this._children.length; i < l; i++) {
|
||||
var item = this._children[i];
|
||||
if (item != clipItem)
|
||||
|
|
|
@ -2449,14 +2449,16 @@ function(name) {
|
|||
// so we draw onto it, instead of the parentCtx
|
||||
ctx = tempCanvas.getContext('2d');
|
||||
}
|
||||
ctx.save();
|
||||
if (!param.clipping)
|
||||
ctx.save();
|
||||
// Translate the context so the topLeft of the item is at (0, 0)
|
||||
// on the temporary canvas.
|
||||
if (tempCanvas)
|
||||
ctx.translate(-itemOffset.x, -itemOffset.y);
|
||||
item._matrix.applyToContext(ctx);
|
||||
item.draw(ctx, param);
|
||||
ctx.restore();
|
||||
if (!param.clipping)
|
||||
ctx.restore();
|
||||
// If we created a temporary canvas before, composite it onto the
|
||||
// parent canvas:
|
||||
if (tempCanvas) {
|
||||
|
|
Loading…
Reference in a new issue