mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -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.width = coords[2] - coords[0];
|
||||
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() {
|
||||
|
@ -39,14 +47,14 @@ PlacedSymbol = Item.extend({
|
|||
},
|
||||
|
||||
draw: function(ctx, param) {
|
||||
// TODO: BlendMode isn't working yet for PlacedSymbols.
|
||||
if(this.blendMode != 'normal' && !param.ignoreBlendMode) {
|
||||
BlendMode.process(ctx, this, param);
|
||||
} else {
|
||||
param.ignoreBlendMode = false;
|
||||
// TODO: we need to preserve strokewidth, but still transform the fill
|
||||
ctx.save();
|
||||
this.matrix.applyToContext(ctx);
|
||||
if(param.ignoreBlendMode !== true)
|
||||
this.matrix.applyToContext(ctx);
|
||||
param.ignoreBlendMode = false;
|
||||
this.symbol.definition.draw(ctx, param);
|
||||
ctx.restore();
|
||||
}
|
||||
|
|
|
@ -159,6 +159,14 @@ Raster = Item.extend({
|
|||
bounds.y = coords[1];
|
||||
bounds.width = coords[2] - coords[0];
|
||||
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() {
|
||||
|
@ -169,12 +177,13 @@ Raster = Item.extend({
|
|||
if(this.blendMode != 'normal' && !param.ignoreBlendMode) {
|
||||
BlendMode.process(ctx, this, param);
|
||||
} else {
|
||||
param.ignoreBlendMode = false;
|
||||
ctx.save();
|
||||
this.matrix.applyToContext(ctx);
|
||||
if(param.ignoreBlendMode !== true)
|
||||
this.matrix.applyToContext(ctx);
|
||||
ctx.drawImage(this._canvas || this._image,
|
||||
-this.size.width / 2, -this.size.height / 2);
|
||||
ctx.restore();
|
||||
param.ignoreBlendMode = false;
|
||||
}
|
||||
}
|
||||
}, new function() {
|
||||
|
|
Loading…
Reference in a new issue