mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
parent
84a75e375a
commit
e38829eb96
6 changed files with 14 additions and 12 deletions
|
@ -3954,11 +3954,13 @@ new function() { // // Scope to inject various item event handlers
|
|||
}
|
||||
}
|
||||
if (shadowColor) {
|
||||
var shadowBlur = style.getShadowBlur();
|
||||
if (shadowBlur > 0) {
|
||||
var blur = style.getShadowBlur(),
|
||||
offset = this.getShadowOffset();
|
||||
// In order to draw a shadow, we need either a shadow blur or an
|
||||
// offset, or both.
|
||||
if (blur > 0 || !offset.isZero()) {
|
||||
ctx.shadowColor = shadowColor.toCanvasStyle(ctx);
|
||||
ctx.shadowBlur = shadowBlur;
|
||||
var offset = this.getShadowOffset();
|
||||
ctx.shadowBlur = blur;
|
||||
ctx.shadowOffsetX = offset.x;
|
||||
ctx.shadowOffsetY = offset.y;
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ var Shape = Item.extend(/** @lends Shape# */{
|
|||
this._setStyles(ctx);
|
||||
if (hasFill) {
|
||||
ctx.fill(style.getFillRule());
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.shadowColor = 'rgba(0,0,0,0)';
|
||||
}
|
||||
if (hasStroke)
|
||||
ctx.stroke();
|
||||
|
|
|
@ -285,7 +285,7 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
|
|||
var style = this._style;
|
||||
if (style.hasFill()) {
|
||||
ctx.fill(style.getFillRule());
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.shadowColor = 'rgba(0,0,0,0)';
|
||||
}
|
||||
if (style.hasStroke())
|
||||
ctx.stroke();
|
||||
|
|
|
@ -2171,7 +2171,7 @@ new function() { // Scope for drawing
|
|||
// If shadowColor is defined, clear it after fill, so it
|
||||
// won't be applied to both fill and stroke. If the path is
|
||||
// only stroked, we don't have to clear it.
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.shadowColor = 'rgba(0,0,0,0)';
|
||||
}
|
||||
if (hasStroke) {
|
||||
if (dashLength) {
|
||||
|
|
|
@ -293,7 +293,7 @@ var Style = Base.extend(new function() {
|
|||
|
||||
// DOCS: Style#hasShadow()
|
||||
hasShadow: function() {
|
||||
return !!this.getShadowColor() && this.getShadowBlur() > 0;
|
||||
return !!this.getShadowColor();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -85,16 +85,16 @@ var PointText = TextItem.extend(/** @lends PointText# */{
|
|||
hasFill = style.hasFill(),
|
||||
hasStroke = style.hasStroke(),
|
||||
leading = style.getLeading(),
|
||||
shadowBlur = ctx.shadowBlur;
|
||||
shadowColor = ctx.shadowColor;
|
||||
ctx.font = style.getFontStyle();
|
||||
ctx.textAlign = style.getJustification();
|
||||
for (var i = 0, l = lines.length; i < l; i++) {
|
||||
// See Path._draw() for explanation about ctx.shadowBlur
|
||||
ctx.shadowBlur = shadowBlur;
|
||||
// See Path._draw() for explanation about ctx.shadowColor
|
||||
ctx.shadowColor = shadowColor;
|
||||
var line = lines[i];
|
||||
if (hasFill) {
|
||||
ctx.fillText(line, 0, 0);
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.shadowColor = 'rgba(0,0,0,0)';
|
||||
}
|
||||
if (hasStroke)
|
||||
ctx.strokeText(line, 0, 0);
|
||||
|
|
Loading…
Reference in a new issue