UNPKG

@peakpay/excalidraw

Version:
54 lines (53 loc) 2.82 kB
import { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, NonDeleted } from "./types"; import { Drawable, Op } from "roughjs/bin/core"; import { Point } from "../types"; export type RectangleBox = { x: number; y: number; width: number; height: number; angle: number; }; export type Bounds = readonly [x1: number, y1: number, x2: number, y2: number]; export declare class ElementBounds { private static boundsCache; static getBounds(element: ExcalidrawElement): Bounds; private static calculateBounds; } export declare const getElementAbsoluteCoords: (element: ExcalidrawElement, includeBoundText?: boolean) => [number, number, number, number, number, number]; /** * for a given element, `getElementLineSegments` returns line segments * that can be used for visual collision detection (useful for frames) * as opposed to bounding box collision detection */ export declare const getElementLineSegments: (element: ExcalidrawElement) => [Point, Point][]; /** * Scene -> Scene coords, but in x1,x2,y1,y2 format. * * Rectangle here means any rectangular frame, not an excalidraw element. */ export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBox) => number[]; export declare const pointRelativeTo: (element: ExcalidrawElement, absoluteCoords: readonly [number, number]) => readonly [number, number]; export declare const getDiamondPoints: (element: ExcalidrawElement) => number[]; export declare const getCurvePathOps: (shape: Drawable) => Op[]; export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: ((x: number, y: number) => [number, number]) | undefined) => [number, number, number, number]; export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null; export declare const getElementBounds: (element: ExcalidrawElement) => Bounds; export declare const getCommonBounds: (elements: readonly ExcalidrawElement[]) => Bounds; export declare const getResizedElementAbsoluteCoords: (element: ExcalidrawElement, nextWidth: number, nextHeight: number, normalizePoints: boolean) => [number, number, number, number]; export declare const getElementPointsCoords: (element: ExcalidrawLinearElement, points: readonly (readonly [number, number])[]) => [number, number, number, number]; export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: { x: number; y: number; }) => Bounds; export interface BoundingBox { minX: number; minY: number; maxX: number; maxY: number; midX: number; midY: number; width: number; height: number; } export declare const getCommonBoundingBox: (elements: ExcalidrawElement[] | readonly NonDeleted<ExcalidrawElement>[]) => BoundingBox;