mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -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,
|
ExcalidrawBindableElement,
|
||||||
FontFamilyValues,
|
FontFamilyValues,
|
||||||
FontString,
|
FontString,
|
||||||
|
ExcalidrawElement,
|
||||||
} from "@excalidraw/element/types";
|
} from "@excalidraw/element/types";
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
|
@ -1201,3 +1202,13 @@ export const escapeDoubleQuotes = (str: string) => {
|
||||||
|
|
||||||
export const castArray = <T>(value: T | T[]): T[] =>
|
export const castArray = <T>(value: T | T[]): T[] =>
|
||||||
Array.isArray(value) ? value : [value];
|
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
Add a link
Reference in a new issue