Fix problem on fabric.Line controls and line.getWidth() (#3742)

* feat(pr/fixLineWidth) Fix problem on fabric.Line controls and line.getWidth()

* fix line boxes and svg import
This commit is contained in:
Edwin Guzman 2017-02-25 16:17:24 -04:00 committed by Andrea Bogazzi
parent 14e8826173
commit 1f55de07c4

View file

@ -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)
);
}
@ -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;
}
}