diff --git a/components/packages/Train/Train.js b/components/packages/Train/Train.js index 13a81ff..24cef17 100644 --- a/components/packages/Train/Train.js +++ b/components/packages/Train/Train.js @@ -112,11 +112,11 @@ class TrainBody extends Container { this.bodyRact.clear(); } getBodyWH() { - const bodyAWH = this.codeAGraph.getLocalBounds(); - const bodyBWH = this.codeBGraph.getLocalBounds(); + const bodyAWH = this.codeAGraph.localBoundsToCanvasPoints(); + const bodyBWH = this.codeBGraph.localBoundsToCanvasPoints(); return { - width: bodyAWH.width + bodyBWH.width + this.train.constDatas.bodyPadding * 2, - height: bodyAWH.height + this.train.constDatas.bodyPadding * 2, + width: bodyAWH[1].x - bodyAWH[0].x + bodyBWH[1].x - bodyBWH[0].x, + height: bodyAWH[2].y - bodyAWH[1].y, }; } doRepaint() { diff --git a/src/packages/Train/Train.ts b/src/packages/Train/Train.ts index eaad4e0..7e1f77a 100644 --- a/src/packages/Train/Train.ts +++ b/src/packages/Train/Train.ts @@ -128,12 +128,11 @@ class TrainBody extends Container { } getBodyWH(): bodyWH { - const bodyAWH = this.codeAGraph.getLocalBounds(); - const bodyBWH = this.codeBGraph.getLocalBounds(); + const bodyAWH = this.codeAGraph.localBoundsToCanvasPoints(); + const bodyBWH = this.codeBGraph.localBoundsToCanvasPoints(); return { - width: - bodyAWH.width + bodyBWH.width + this.train.constDatas.bodyPadding * 2, - height: bodyAWH.height + this.train.constDatas.bodyPadding * 2, + width: bodyAWH[1].x - bodyAWH[0].x + bodyBWH[1].x - bodyBWH[0].x, + height: bodyAWH[2].y - bodyAWH[1].y, }; }