feat: Orthogonal (elbow) arrows for diagramming (#8299)

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Márk Tolmács 2024-08-01 18:39:03 +02:00 committed by GitHub
parent a133a70e87
commit 15e019706d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
69 changed files with 5415 additions and 1144 deletions

View file

@ -13,6 +13,7 @@ exports[`exportToSvg > with default arguments 1`] = `
"contextMenu": null,
"currentChartType": "bar",
"currentHoveredFontFamily": null,
"currentItemArrowType": "round",
"currentItemBackgroundColor": "transparent",
"currentItemEndArrowhead": "arrow",
"currentItemFillStyle": "solid",

View file

@ -16,10 +16,22 @@ const DEFAULT_THRESHOLD = 10e-5;
*/
// the two vectors are ao and bo
export const cross = (a: Point, b: Point, o: Point) => {
export const cross = (
a: Readonly<Point>,
b: Readonly<Point>,
o: Readonly<Point>,
) => {
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
};
export const dot = (
a: Readonly<Point>,
b: Readonly<Point>,
o: Readonly<Point>,
) => {
return (a[0] - o[0]) * (b[0] - o[0]) + (a[1] - o[1]) * (b[1] - o[1]);
};
export const isClosed = (polygon: Polygon) => {
const first = polygon[0];
const last = polygon[polygon.length - 1];
@ -36,7 +48,9 @@ export const close = (polygon: Polygon) => {
// convert radians to degress
export const angleToDegrees = (angle: number) => {
return (angle * 180) / Math.PI;
const theta = (angle * 180) / Math.PI;
return theta < 0 ? 360 + theta : theta;
};
// convert degrees to radians