Skip to content

Commit 0355b36

Browse files
committed
🐛 防止连线两端是巨大框时,连线变得巨大
1 parent a92f29c commit 0355b36

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

app/src/core/render/canvas2d/entityRenderer/edge/concrete/StraightEdgeRenderer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ export class StraightEdgeRenderer extends EdgeRendererClass {
7575
if (edge.target instanceof Section && edge.source instanceof Section) {
7676
const rect1 = edge.source.collisionBox.getRectangle();
7777
const rect2 = edge.target.collisionBox.getRectangle();
78-
edgeWidth = Math.max(rect1.width, rect2.width, rect1.height, rect2.height) / 100;
78+
edgeWidth = Math.min(
79+
Math.min(Math.max(rect1.width, rect1.height), Math.max(rect2.width, rect2.height)) / 100,
80+
100,
81+
);
7982
}
8083

8184
if (edge.text.trim() === "") {

app/src/core/render/canvas2d/entityRenderer/section/SectionRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export namespace SectionRenderer {
9393
}
9494

9595
export function renderBigTitle(section: Section) {
96-
if (Camera.currentScale < 0.2) {
96+
if (Camera.currentScale < Section.bigTitleCameraScale) {
9797
const fontSizeVector = getFontSizeBySectionSize(section);
9898
const fontHeight = fontSizeVector.y;
9999
ShapeRenderer.renderRect(

app/src/core/stage/stageObject/entity/Section.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export class Section extends ConnectableEntity {
2626
private _collisionBoxWhenCollapsed: CollisionBox;
2727
private _collisionBoxNormal: CollisionBox;
2828

29+
/**
30+
* 小于多少的情况下,开始渲染大标题
31+
*/
32+
static bigTitleCameraScale = 0.2;
33+
2934
public get collisionBox(): CollisionBox {
3035
if (this.isCollapsed) {
3136
return this._collisionBoxWhenCollapsed;

0 commit comments

Comments
 (0)