1
0
mirror of https://github.com/kalmarek/SmallHyperbolic synced 2024-11-30 09:10:27 +01:00

use bezier instead of elliptic arrows

This commit is contained in:
Marek Kaluba 2022-02-24 02:34:58 +01:00
parent 8df415ca59
commit 007a8bcece
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15

View File

@ -24,11 +24,23 @@ function drag(simulation) {
} }
function linkArc(d) { function linkArc(d) {
const r = Math.hypot(d.target.x - d.source.x, d.target.y - d.source.y); let r = Math.hypot(d.target.x - d.source.x, d.target.y - d.source.y);
r = 40*Math.exp(r/50)
// r = 50 + 2*(r/20)**3
// Elliptical arc:
// return `
// M${d.source.x},${d.source.y}
// A${r},${r} 0 0,1 ${d.target.x},${d.target.y}
// `;
let xmid = (d.source.x + d.target.x) / 2
let ymid = (d.source.y + d.target.y) / 2
// cubic smooth Bezier
return ` return `
M${d.source.x},${d.source.y} M${d.source.x} ${d.source.y}
A${r},${r} 0 0,1 ${d.target.x},${d.target.y} S${xmid - 0.01*ymid} ${ymid + 0.01*xmid}
`; ${d.target.x},${d.target.y}
`
;
} }
function highlight(node) { function highlight(node) {