arcs nicely curve when they connect a rountangle to itself
This commit is contained in:
parent
e009f718d2
commit
da0e56e17c
11 changed files with 526 additions and 153 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { RountanglePart } from "./editor_types";
|
||||
|
||||
export type Vec2D = {
|
||||
x: number;
|
||||
y: number;
|
||||
|
|
@ -161,3 +163,36 @@ export function getBottomSide(rect: Rect2D): Line2D {
|
|||
end: { x: rect.topLeft.x + rect.size.x, y: rect.topLeft.y + rect.size.y },
|
||||
};
|
||||
}
|
||||
|
||||
export type ArcDirection = "no" | "cw" | "ccw";
|
||||
|
||||
export function arcDirection(start: RountanglePart, end: RountanglePart): ArcDirection {
|
||||
if (start === end) {
|
||||
if (start === "left" || start === "top") {
|
||||
return "ccw";
|
||||
}
|
||||
else {
|
||||
return "cw";
|
||||
}
|
||||
}
|
||||
const both = [start, end];
|
||||
if (both.includes("top") && both.includes("bottom")) {
|
||||
return "no";
|
||||
}
|
||||
if (both.includes("left") && both.includes("right")) {
|
||||
return "no";
|
||||
}
|
||||
if (start === "top" && end === "left") {
|
||||
return "ccw";
|
||||
}
|
||||
if (start === "left" && end === "bottom") {
|
||||
return "ccw";
|
||||
}
|
||||
if (start === "bottom" && end === "right") {
|
||||
return "ccw";
|
||||
}
|
||||
if (start === "right" && end === "top") {
|
||||
return "ccw";
|
||||
}
|
||||
return "cw";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue