mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-11 07:13:09 +00:00
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:
parent
14e8826173
commit
1f55de07c4
1 changed files with 6 additions and 5 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue