fix: Diamond arrowheads

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs
2026-03-22 13:54:46 +00:00
parent d04eef5a37
commit 8059518d85
+5 -24
View File
@@ -893,30 +893,11 @@ export const getArrowheadPoints = (
);
if (arrowhead === "diamond" || arrowhead === "diamond_outline") {
// point opposite to the arrowhead point
let ox;
let oy;
if (position === "start") {
const [px, py] = element.points.length > 1 ? element.points[1] : [0, 0];
[ox, oy] = pointRotateRads(
pointFrom(tx + minSize * 2, ty),
pointFrom(tx, ty),
Math.atan2(py - ty, px - tx) as Radians,
);
} else {
const [px, py] =
element.points.length > 1
? element.points[element.points.length - 2]
: [0, 0];
[ox, oy] = pointRotateRads(
pointFrom(tx - minSize * 2, ty),
pointFrom(tx, ty),
Math.atan2(ty - py, tx - px) as Radians,
);
}
// point opposite to the arrowhead point — use the same Bezier tangent
// direction (nx, ny) as the wings so the diamond isn't distorted on
// rounded arrows where the tangent differs from the chord direction.
const ox = tx - nx * minSize * 2;
const oy = ty - ny * minSize * 2;
return [tx, ty, x3, y3, ox, oy, x4, y4];
}