diff --git a/src/item/Item.js b/src/item/Item.js index ca9f6880..ad65f1ce 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -142,8 +142,8 @@ var Item = this.Item = Base.extend({ setClipMask: function(clipMask) { this._clipMask = clipMask; if (this._clipMask) { - this.fillColor = null; - this.strokeColor = null; + this.setFillColor(null); + this.setStrokeColor(null); } }, @@ -723,8 +723,8 @@ var Item = this.Item = Base.extend({ // since otherwise their stroke is drawn half transparent over their // fill. if (item.blendMode !== 'normal' - || item.opacity < 1 - && !(item.segments && (!item.fillColor || !item.strokeColor))) { + || item.opacity < 1 + && !(item.segments && (!item.getFillColor() || !item.getStrokeColor()))) { var bounds = item.getStrokeBounds() || item.getBounds(); if (!bounds.width || !bounds.height) return; diff --git a/src/item/PathStyle.js b/src/item/PathStyle.js index 299147c0..0f27ccbc 100644 --- a/src/item/PathStyle.js +++ b/src/item/PathStyle.js @@ -26,7 +26,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() { fields[set] = function(value) { if (this.item && this.item.children) { for (var i = 0, l = this.item.children.length; i < l; i++) { - this.item.children[i].getStyle()[set](value); + this.item.children[i]._style[set](value); } } else { this['_' + key] = isColor ? Color.read(arguments) : value; @@ -37,7 +37,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() { if (this.item && this.item.children) { var style; for (var i = 0, l = this.item.children.length; i < l; i++) { - var childStyle = this.item.children[i].getStyle()[get](); + var childStyle = this.item.children[i]._style[get](); if (!style) { style = childStyle; } else if (style != childStyle) { diff --git a/src/path/CompoundPath.js b/src/path/CompoundPath.js index 7971b10c..998f89d5 100644 --- a/src/path/CompoundPath.js +++ b/src/path/CompoundPath.js @@ -66,12 +66,14 @@ var CompoundPath = this.CompoundPath = PathItem.extend({ Item.draw(this.children[i], ctx, param); } firstChild.setCtxStyles(ctx); - if (firstChild.fillColor) { - ctx.fillStyle = firstChild.fillColor.toCssString(); + var fillColor = firstChild.getFillColor(), + strokeColor = firstChild.getStrokeColor(); + if (fillColor) { + ctx.fillStyle = fillColor.toCssString(); ctx.fill(); } - if (firstChild.strokeColor) { - ctx.strokeStyle = firstChild.strokeColor.toCssString(); + if (strokeColor) { + ctx.strokeStyle = strokeColor.toCssString(); ctx.stroke(); } } diff --git a/src/path/Path.js b/src/path/Path.js index 476b7c00..89ad2120 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -393,20 +393,22 @@ var Path = this.Path = PathItem.extend({ } // If the path is part of a compound path or doesn't have a fill or // stroke, there is no need to continue. - if (!param.compound && (this.fillColor || this.strokeColor)) { + var fillColor = this.getFillColor(), + strokeColor = this.getStrokeColor(); + if (!param.compound && (fillColor || strokeColor)) { this.setCtxStyles(ctx); ctx.save(); // If the path only defines a strokeColor or a fillColor, // draw it directly with the globalAlpha set, otherwise // we will do it later when we composite the temporary canvas. - if (!this.fillColor || !this.strokeColor) + if (!fillColor || !strokeColor) ctx.globalAlpha = this.opacity; - if (this.fillColor) { - ctx.fillStyle = this.fillColor.getCanvasStyle(ctx); + if (fillColor) { + ctx.fillStyle = fillColor.getCanvasStyle(ctx); ctx.fill(); } - if (this.strokeColor) { - ctx.strokeStyle = this.strokeColor.getCanvasStyle(ctx); + if (strokeColor) { + ctx.strokeStyle = strokeColor.getCanvasStyle(ctx); ctx.stroke(); } ctx.restore(); @@ -515,11 +517,11 @@ var Path = this.Path = PathItem.extend({ return x; }; - var styleNames = { - strokeWidth: 'lineWidth', - strokeJoin: 'lineJoin', - strokeCap: 'lineCap', - miterLimit: 'miterLimit' + var styles = { + getStrokeWidth: 'lineWidth', + getStrokeJoin: 'lineJoin', + getStrokeCap: 'lineCap', + getMiterLimit: 'miterLimit' }; return { @@ -645,11 +647,12 @@ var Path = this.Path = PathItem.extend({ } }, - setCtxStyles: function(ctx) { - for (var i in styleNames) { + setCtxStyles: function(context) { + for (var i in styles) { var style; - if (style = this[i]) - ctx[styleNames[i]] = style; + if (style = this[i]()) { + context[styles[i]] = style; + } } } };