Skip to content

Commit

Permalink
Fix problem on fabric.Line controls and line.getWidth() (#3742)
Browse files Browse the repository at this point in the history
* feat(pr/fixLineWidth) Fix problem on fabric.Line controls and line.getWidth()

* fix line boxes and svg import
  • Loading branch information
vudduu authored and asturur committed Feb 26, 2017
1 parent 7873c4f commit c1ff02e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/shapes/line.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,11 @@
// Line coords are distances from left-top of canvas to origin of line.
// To render line in a path-group, we need to translate them to
// distances from center of path-group to center of line.
var cp = this.getCenterPoint();
var cp = this.getCenterPoint(),
offset = this.strokeWidth / 2;
ctx.translate(
cp.x - this.strokeWidth / 2,
cp.y - this.strokeWidth / 2
cp.x - (this.strokeLineCap === 'butt' && this.height === 0 ? 0 : offset),
cp.y - (this.strokeLineCap === 'butt' && this.width === 0 ? 0 : offset)
);
}

Expand Down Expand Up @@ -222,10 +223,10 @@
_getNonTransformedDimensions: function() {
var dim = this.callSuper('_getNonTransformedDimensions');
if (this.strokeLineCap === 'butt') {
if (dim.x === 0) {
if (this.width === 0) {
dim.y -= this.strokeWidth;
}
if (dim.y === 0) {
if (this.height === 0) {
dim.x -= this.strokeWidth;
}
}
Expand Down

0 comments on commit c1ff02e

Please sign in to comment.