Fix line.getClientRect() calculations for line with a tension or low number of points

This commit is contained in:
Anton Lavrenov
2019-10-02 08:00:06 -05:00
parent a41deff5a9
commit cf27503518
6 changed files with 108 additions and 8 deletions

View File

@@ -185,9 +185,23 @@ export class Line<Config extends LineConfig = LineConfig> extends Shape<
}
// overload size detection
getSelfRect() {
var points;
var points = this.points();
if (points.length < 4) {
return {
x: points[0] || 0,
y: points[1] || 0,
width: 0,
height: 0
};
}
if (this.tension() !== 0) {
points = this._getTensionPoints();
points = [
points[0],
points[1],
...this._getTensionPoints(),
points[points.length - 2],
points[points.length - 2]
];
} else {
points = this.points();
}