mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
feat: Orthogonal (elbow) arrows for diagramming (#8299)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
@ -13,6 +13,7 @@ exports[`exportToSvg > with default arguments 1`] = `
|
||||
"contextMenu": null,
|
||||
"currentChartType": "bar",
|
||||
"currentHoveredFontFamily": null,
|
||||
"currentItemArrowType": "round",
|
||||
"currentItemBackgroundColor": "transparent",
|
||||
"currentItemEndArrowhead": "arrow",
|
||||
"currentItemFillStyle": "solid",
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user