diff --git a/src/shapes/image.class.js b/src/shapes/image.class.js index 804e59df2e2..649df65660a 100644 --- a/src/shapes/image.class.js +++ b/src/shapes/image.class.js @@ -164,12 +164,17 @@ * @param {CanvasRenderingContext2D} ctx Context to render on */ _stroke: function(ctx) { - ctx.save(); - this._setStrokeStyles(ctx); + if (!this.stroke || this.strokeWidth === 0) { + return; + } + var w = this.width / 2, h = this.height / 2; ctx.beginPath(); - ctx.strokeRect(-this.width / 2, -this.height / 2, this.width, this.height); + ctx.moveTo(-w, -h); + ctx.lineTo(w, -h); + ctx.lineTo(w, h); + ctx.lineTo(-w, h); + ctx.lineTo(-w, -h); ctx.closePath(); - ctx.restore(); }, /** @@ -410,6 +415,7 @@ imageMargins.height ); + this._stroke(ctx); this._renderStroke(ctx); }, diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index 8ea1359cb84..95f8df72695 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -1192,20 +1192,21 @@ } if (supportsLineDash) { ctx.setLineDash(this.strokeDashArray); - this._stroke && this._stroke(ctx); } else { this._renderDashedStroke && this._renderDashedStroke(ctx); } - ctx.stroke(); } - else { - if (this.stroke.gradientTransform) { - var g = this.stroke.gradientTransform; - ctx.transform.apply(ctx, g); - } - this._stroke ? this._stroke(ctx) : ctx.stroke(); + if (this.stroke.gradientTransform) { + var g = this.stroke.gradientTransform; + ctx.transform.apply(ctx, g); + } + if (this.stroke.toLive) { + ctx.translate( + -this.width / 2 + this.stroke.offsetX || 0, + -this.height / 2 + this.stroke.offsetY || 0); } + ctx.stroke(); ctx.restore(); },