From b1ddba6a5159c065c0b64d3992da63c04294508e Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 1 May 2016 12:26:27 +0200 Subject: [PATCH 1/4] Update image.class.js --- src/shapes/image.class.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/shapes/image.class.js b/src/shapes/image.class.js index 804e59df2e2..9f8517731ce 100644 --- a/src/shapes/image.class.js +++ b/src/shapes/image.class.js @@ -164,12 +164,12 @@ * @param {CanvasRenderingContext2D} ctx Context to render on */ _stroke: function(ctx) { - ctx.save(); - this._setStrokeStyles(ctx); + if (!this.stroke || this.strokeWidth === 0) { + return; + } ctx.beginPath(); ctx.strokeRect(-this.width / 2, -this.height / 2, this.width, this.height); ctx.closePath(); - ctx.restore(); }, /** @@ -410,6 +410,7 @@ imageMargins.height ); + this._stroke(ctx); this._renderStroke(ctx); }, From f136285db8a59fe4b9de255b6790dcab1c8019d8 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 1 May 2016 12:28:47 +0200 Subject: [PATCH 2/4] Update object.class.js --- src/shapes/object.class.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index 7eabcded9a2..962f48eb148 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -1185,20 +1185,16 @@ } 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); } + ctx.stroke(); ctx.restore(); }, From b5562805f134c61dcff8b2536a5237c3601e55f5 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 1 May 2016 12:39:24 +0200 Subject: [PATCH 3/4] Update image.class.js --- src/shapes/image.class.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shapes/image.class.js b/src/shapes/image.class.js index 9f8517731ce..649df65660a 100644 --- a/src/shapes/image.class.js +++ b/src/shapes/image.class.js @@ -167,8 +167,13 @@ 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(); }, From 724fcdde80cf1926690b5ca12265e801d238eaa5 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 1 May 2016 13:59:53 +0200 Subject: [PATCH 4/4] add missing stroke translation --- src/shapes/object.class.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index 962f48eb148..586edb8aa0e 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -1194,6 +1194,11 @@ 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(); },