mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
refactor: add elementCenterPoint util
This commit is contained in:
parent
6fc85022ae
commit
6290d76927
1 changed files with 11 additions and 0 deletions
|
@ -4,6 +4,7 @@ import type {
|
|||
ExcalidrawBindableElement,
|
||||
FontFamilyValues,
|
||||
FontString,
|
||||
ExcalidrawElement,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import type {
|
||||
|
@ -1201,3 +1202,13 @@ export const escapeDoubleQuotes = (str: string) => {
|
|||
|
||||
export const castArray = <T>(value: T | T[]): T[] =>
|
||||
Array.isArray(value) ? value : [value];
|
||||
|
||||
export const elementCenterPoint = (element: ExcalidrawElement) => {
|
||||
const { x, y, width, height } = element;
|
||||
|
||||
const centerXPoint = x + width / 2;
|
||||
|
||||
const centerYPoint = y + height / 2;
|
||||
|
||||
return { x: centerXPoint, y: centerYPoint };
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue