mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
PlacedSymbol & Raster: fix transformContent and support BlendMode.
This commit is contained in:
parent
049504a67a
commit
f79e6a0454
2 changed files with 22 additions and 5 deletions
|
@ -32,6 +32,14 @@ PlacedSymbol = Item.extend({
|
||||||
bounds.y = coords[1];
|
bounds.y = coords[1];
|
||||||
bounds.width = coords[2] - coords[0];
|
bounds.width = coords[2] - coords[0];
|
||||||
bounds.height = coords[3] - coords[1];
|
bounds.height = coords[3] - coords[1];
|
||||||
|
if (bounds.width < 0) {
|
||||||
|
bounds.x = coords[2];
|
||||||
|
bounds.width = -bounds.width;
|
||||||
|
}
|
||||||
|
if (bounds.height < 0) {
|
||||||
|
bounds.y = coords[3];
|
||||||
|
bounds.height = bounds.height;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getBounds: function() {
|
getBounds: function() {
|
||||||
|
@ -39,14 +47,14 @@ PlacedSymbol = Item.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
draw: function(ctx, param) {
|
draw: function(ctx, param) {
|
||||||
// TODO: BlendMode isn't working yet for PlacedSymbols.
|
|
||||||
if(this.blendMode != 'normal' && !param.ignoreBlendMode) {
|
if(this.blendMode != 'normal' && !param.ignoreBlendMode) {
|
||||||
BlendMode.process(ctx, this, param);
|
BlendMode.process(ctx, this, param);
|
||||||
} else {
|
} else {
|
||||||
param.ignoreBlendMode = false;
|
|
||||||
// TODO: we need to preserve strokewidth, but still transform the fill
|
// TODO: we need to preserve strokewidth, but still transform the fill
|
||||||
ctx.save();
|
ctx.save();
|
||||||
this.matrix.applyToContext(ctx);
|
if(param.ignoreBlendMode !== true)
|
||||||
|
this.matrix.applyToContext(ctx);
|
||||||
|
param.ignoreBlendMode = false;
|
||||||
this.symbol.definition.draw(ctx, param);
|
this.symbol.definition.draw(ctx, param);
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,14 @@ Raster = Item.extend({
|
||||||
bounds.y = coords[1];
|
bounds.y = coords[1];
|
||||||
bounds.width = coords[2] - coords[0];
|
bounds.width = coords[2] - coords[0];
|
||||||
bounds.height = coords[3] - coords[1];
|
bounds.height = coords[3] - coords[1];
|
||||||
|
if (bounds.width < 0) {
|
||||||
|
bounds.x = coords[2];
|
||||||
|
bounds.width = -bounds.width;
|
||||||
|
}
|
||||||
|
if (bounds.height < 0) {
|
||||||
|
bounds.y = coords[3];
|
||||||
|
bounds.height = bounds.height;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getBounds: function() {
|
getBounds: function() {
|
||||||
|
@ -169,12 +177,13 @@ Raster = Item.extend({
|
||||||
if(this.blendMode != 'normal' && !param.ignoreBlendMode) {
|
if(this.blendMode != 'normal' && !param.ignoreBlendMode) {
|
||||||
BlendMode.process(ctx, this, param);
|
BlendMode.process(ctx, this, param);
|
||||||
} else {
|
} else {
|
||||||
param.ignoreBlendMode = false;
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
this.matrix.applyToContext(ctx);
|
if(param.ignoreBlendMode !== true)
|
||||||
|
this.matrix.applyToContext(ctx);
|
||||||
ctx.drawImage(this._canvas || this._image,
|
ctx.drawImage(this._canvas || this._image,
|
||||||
-this.size.width / 2, -this.size.height / 2);
|
-this.size.width / 2, -this.size.height / 2);
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
|
param.ignoreBlendMode = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new function() {
|
}, new function() {
|
||||||
|
|
Loading…
Reference in a new issue