mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -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) {
|
draw: function(ctx, param) {
|
||||||
var clipItem = this._getClipItem();
|
var clipItem = this._getClipItem();
|
||||||
if (clipItem)
|
if (clipItem) {
|
||||||
|
param.clipping = true;
|
||||||
Item.draw(clipItem, ctx, param);
|
Item.draw(clipItem, ctx, param);
|
||||||
|
delete param.clipping;
|
||||||
|
}
|
||||||
for (var i = 0, l = this._children.length; i < l; i++) {
|
for (var i = 0, l = this._children.length; i < l; i++) {
|
||||||
var item = this._children[i];
|
var item = this._children[i];
|
||||||
if (item != clipItem)
|
if (item != clipItem)
|
||||||
|
|
|
@ -2449,14 +2449,16 @@ function(name) {
|
||||||
// so we draw onto it, instead of the parentCtx
|
// so we draw onto it, instead of the parentCtx
|
||||||
ctx = tempCanvas.getContext('2d');
|
ctx = tempCanvas.getContext('2d');
|
||||||
}
|
}
|
||||||
ctx.save();
|
if (!param.clipping)
|
||||||
|
ctx.save();
|
||||||
// Translate the context so the topLeft of the item is at (0, 0)
|
// Translate the context so the topLeft of the item is at (0, 0)
|
||||||
// on the temporary canvas.
|
// on the temporary canvas.
|
||||||
if (tempCanvas)
|
if (tempCanvas)
|
||||||
ctx.translate(-itemOffset.x, -itemOffset.y);
|
ctx.translate(-itemOffset.x, -itemOffset.y);
|
||||||
item._matrix.applyToContext(ctx);
|
item._matrix.applyToContext(ctx);
|
||||||
item.draw(ctx, param);
|
item.draw(ctx, param);
|
||||||
ctx.restore();
|
if (!param.clipping)
|
||||||
|
ctx.restore();
|
||||||
// If we created a temporary canvas before, composite it onto the
|
// If we created a temporary canvas before, composite it onto the
|
||||||
// parent canvas:
|
// parent canvas:
|
||||||
if (tempCanvas) {
|
if (tempCanvas) {
|
||||||
|
|
Loading…
Reference in a new issue