Fix diamond distance

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2024-09-28 09:09:14 +02:00
parent 34ec751501
commit c41486abd1
No known key found for this signature in database
4 changed files with 74 additions and 53 deletions

View file

@ -30,7 +30,7 @@ import {
type GlobalPoint,
type LocalPoint,
} from "../../math";
import { getCornerRadius } from "../shapes";
import { getCornerRadius, getDiamondPoints } from "../shapes";
const getDashArrayDashed = (strokeWidth: number) => [8, 8 + strokeWidth];
@ -278,21 +278,6 @@ const getArrowheadShapes = (
}
};
export const getDiamondPoints = (element: ExcalidrawElement) => {
// Here we add +1 to avoid these numbers to be 0
// otherwise rough.js will throw an error complaining about it
const topX = Math.floor(element.width / 2) + 1;
const topY = 0;
const rightX = element.width;
const rightY = Math.floor(element.height / 2) + 1;
const bottomX = topX;
const bottomY = element.height;
const leftX = 0;
const leftY = rightY;
return [topX, topY, rightX, rightY, bottomX, bottomY, leftX, leftY];
};
/**
* Generates the roughjs shape for given element.
*