Group: fix clipping. Fixes #66

This commit is contained in:
Jonathan Puckey 2012-03-02 11:54:11 +01:00
parent c339ffca35
commit 2fff5b4f79
2 changed files with 8 additions and 3 deletions

View file

@ -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)

View file

@ -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) {