Skip to content

Commit

Permalink
Add missing stroke.live translation, allow gradientTransform for dash…
Browse files Browse the repository at this point in the history
…ed line.
  • Loading branch information
asturur committed May 1, 2016
1 parent 2006320 commit 6fd1f8a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
14 changes: 10 additions & 4 deletions src/shapes/image.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},

/**
Expand Down Expand Up @@ -410,6 +415,7 @@
imageMargins.height
);

this._stroke(ctx);
this._renderStroke(ctx);
},

Expand Down
17 changes: 9 additions & 8 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},

Expand Down

0 comments on commit 6fd1f8a

Please sign in to comment.