mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Redraw clipItem when drawing into separate canvas for blend-modes.
Closes #228.
This commit is contained in:
parent
20f7c567aa
commit
94e07e77f0
1 changed files with 9 additions and 4 deletions
|
@ -2867,9 +2867,10 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
// over their fill.
|
// over their fill.
|
||||||
// Exclude Raster items since they never draw a stroke and handle
|
// Exclude Raster items since they never draw a stroke and handle
|
||||||
// opacity by themselves (they also don't call _setStyles)
|
// opacity by themselves (they also don't call _setStyles)
|
||||||
var parentCtx, itemOffset, prevOffset;
|
var blending = this._blendMode !== 'normal',
|
||||||
if (this._blendMode !== 'normal' || this._opacity < 1
|
parentCtx, itemOffset, prevOffset;
|
||||||
&& this._type !== 'raster' && (this._type !== 'path'
|
if (blending || this._opacity < 1 && this._type !== 'raster'
|
||||||
|
&& (this._type !== 'path'
|
||||||
|| this.getFillColor() && this.getStrokeColor())) {
|
|| this.getFillColor() && this.getStrokeColor())) {
|
||||||
// Apply the paren't global matrix to the calculation of correct
|
// Apply the paren't global matrix to the calculation of correct
|
||||||
// bounds.
|
// bounds.
|
||||||
|
@ -2895,6 +2896,10 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
ctx.translate(-itemOffset.x, -itemOffset.y);
|
ctx.translate(-itemOffset.x, -itemOffset.y);
|
||||||
// Apply globalMatrix when blitting into temporary canvas.
|
// Apply globalMatrix when blitting into temporary canvas.
|
||||||
(parentCtx ? globalMatrix : this._matrix).applyToContext(ctx);
|
(parentCtx ? globalMatrix : this._matrix).applyToContext(ctx);
|
||||||
|
// If we're blending and a clipItem is defined for the current rendering
|
||||||
|
// loop, we need to draw the clip item again into the separate canvas.
|
||||||
|
if (blending && param.clipItem)
|
||||||
|
param.clipItem.draw(ctx, param.extend({ clip: true }));
|
||||||
this._draw(ctx, param);
|
this._draw(ctx, param);
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
transforms.pop();
|
transforms.pop();
|
||||||
|
@ -2907,7 +2912,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
param.offset = prevOffset;
|
param.offset = prevOffset;
|
||||||
// If the item has a blendMode, use BlendMode#process to
|
// If the item has a blendMode, use BlendMode#process to
|
||||||
// composite its canvas on the parentCanvas.
|
// composite its canvas on the parentCanvas.
|
||||||
if (this._blendMode !== 'normal') {
|
if (blending) {
|
||||||
// The pixel offset of the temporary canvas to the parent
|
// The pixel offset of the temporary canvas to the parent
|
||||||
// canvas.
|
// canvas.
|
||||||
BlendMode.process(this._blendMode, ctx, parentCtx,
|
BlendMode.process(this._blendMode, ctx, parentCtx,
|
||||||
|
|
Loading…
Reference in a new issue