diff --git a/src/item/Item.js b/src/item/Item.js index aa2c24c4c5..eb1fec71e4 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -3918,16 +3918,13 @@ new function() { // // Scope to inject various item event handlers _setStyles: function(ctx) { // We can access internal properties since we're only using this on // items without children, where styles would be merged. - var style = this._style, - fillColor = style.getFillColor(), - strokeColor = style.getStrokeColor(), - shadowColor = style.getShadowColor(); - if (fillColor) - ctx.fillStyle = fillColor.toCanvasStyle(ctx); - if (strokeColor) { + var style = this._style; + if (style.hasFill()) + ctx.fillStyle = style.getFillColor().toCanvasStyle(ctx); + if (style.hasStroke()) { var strokeWidth = style.getStrokeWidth(); if (strokeWidth > 0) { - ctx.strokeStyle = strokeColor.toCanvasStyle(ctx); + ctx.strokeStyle = style.getStrokeColor().toCanvasStyle(ctx); ctx.lineWidth = strokeWidth; var strokeJoin = style.getStrokeJoin(), strokeCap = style.getStrokeCap(), @@ -3953,17 +3950,12 @@ new function() { // // Scope to inject various item event handlers } } } - if (shadowColor) { - 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 = blur; - ctx.shadowOffsetX = offset.x; - ctx.shadowOffsetY = offset.y; - } + if (style.hasShadow()) { + var offset = this.getShadowOffset(); + ctx.shadowColor = style.getShadowColor().toCanvasStyle(ctx); + ctx.shadowBlur = style.getShadowBlur(); + ctx.shadowOffsetX = offset.x; + ctx.shadowOffsetY = offset.y; } }, diff --git a/src/style/Style.js b/src/style/Style.js index 11803f6a34..529ec40ccb 100644 --- a/src/style/Style.js +++ b/src/style/Style.js @@ -283,17 +283,23 @@ var Style = Base.extend(new function() { // DOCS: Style#hasFill() hasFill: function() { - return !!this.getFillColor(); + var color = this.getFillColor(); + return !!color && color.alpha > 0; }, // DOCS: Style#hasStroke() hasStroke: function() { - return !!this.getStrokeColor() && this.getStrokeWidth() > 0; + var color = this.getStrokeColor(); + return !!color && color.alpha > 0 && this.getStrokeWidth() > 0; }, // DOCS: Style#hasShadow() hasShadow: function() { - return !!this.getShadowColor(); + var color = this.getShadowColor(); + // In order to draw a shadow, we need either a shadow blur or an + // offset, or both. + return !!color && color.alpha > 0 && (this.getShadowBlur() > 0 + || !this.getShadowOffset().isZero()); }, /**