Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ed1cfaf

Browse files
feat: implement smooth edges using bezierCurveTo method.
1 parent 58e9cf8 commit ed1cfaf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎src/render/drawTree.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,19 @@ function connectNodesEdge(canvasEle: HTMLCanvasElement | null, xCord: {xStart: n
104104
const start = { x: xStart, y: yStart };
105105
const end = { x: xEnd, y: yEnd };
106106

107+
const xHalf = (xStart + xEnd)/2;
108+
const yHalf = (yStart + yEnd)/2;
109+
110+
const cp1 = { x: xHalf, y: yHalf };
111+
const cp2 = { x: xEnd, y: yHalf };
107112

108113
const context = canvasEle?.getContext("2d");
109114
context?.beginPath();
110115
(context as CanvasRenderingContext2D).strokeStyle = "#6a00f4";
111116
(context as CanvasRenderingContext2D).lineWidth = 2;
112117
context?.moveTo(start.x, start.y);
113-
context?.lineTo(end.x, end.y);
118+
context?.bezierCurveTo(cp1.x, cp1.y, cp2.x, cp2.y, end.x, end.y);
119+
// context?.lineTo(end.x, end.y);
114120
context?.stroke();
115121
}
116122

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /