mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: add support for more UML arrowheads (#7391)
This commit is contained in:
parent
a04cc707c3
commit
b9cfbc2077
15 changed files with 449 additions and 216 deletions
16
src/math.ts
16
src/math.ts
|
@ -15,18 +15,20 @@ import { Mutable } from "./utility-types";
|
|||
import { ShapeCache } from "./scene/ShapeCache";
|
||||
|
||||
export const rotate = (
|
||||
x1: number,
|
||||
y1: number,
|
||||
x2: number,
|
||||
y2: number,
|
||||
// target point to rotate
|
||||
x: number,
|
||||
y: number,
|
||||
// point to rotate against
|
||||
cx: number,
|
||||
cy: number,
|
||||
angle: number,
|
||||
): [number, number] =>
|
||||
// 𝑎′𝑥=(𝑎𝑥−𝑐𝑥)cos𝜃−(𝑎𝑦−𝑐𝑦)sin𝜃+𝑐𝑥
|
||||
// 𝑎′𝑦=(𝑎𝑥−𝑐𝑥)sin𝜃+(𝑎𝑦−𝑐𝑦)cos𝜃+𝑐𝑦.
|
||||
// https://math.stackexchange.com/questions/2204520/how-do-i-rotate-a-line-segment-in-a-specific-point-on-the-line
|
||||
[
|
||||
(x1 - x2) * Math.cos(angle) - (y1 - y2) * Math.sin(angle) + x2,
|
||||
(x1 - x2) * Math.sin(angle) + (y1 - y2) * Math.cos(angle) + y2,
|
||||
(x - cx) * Math.cos(angle) - (y - cy) * Math.sin(angle) + cx,
|
||||
(x - cx) * Math.sin(angle) + (y - cy) * Math.cos(angle) + cy,
|
||||
];
|
||||
|
||||
export const rotatePoint = (
|
||||
|
@ -303,7 +305,7 @@ export const getControlPointsForBezierCurve = (
|
|||
element: NonDeleted<ExcalidrawLinearElement>,
|
||||
endPoint: Point,
|
||||
) => {
|
||||
const shape = ShapeCache.generateElementShape(element);
|
||||
const shape = ShapeCache.generateElementShape(element, null);
|
||||
if (!shape) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue