/** * this file defines pure geometric shapes * * for instance, a cubic bezier curve is specified by its four control points and * an ellipse is defined by its center, angle, semi major axis and semi minor axis * (but in semi-width and semi-height so it's more relevant to Excalidraw) * * the idea with pure shapes is so that we can provide collision and other geoemtric methods not depending on * the specifics of roughjs or elements in Excalidraw; instead, we can focus on the pure shapes themselves * * also included in this file are methods for converting an Excalidraw element or a Drawable from roughjs * to pure shapes */ import type { Curve, LineSegment, Polygon, Radians } from "@excalidraw/math"; import { type GlobalPoint, type LocalPoint } from "@excalidraw/math"; import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawTextElement } from "@excalidraw/excalidraw/element/types"; import type { Drawable, Op } from "roughjs/bin/core"; export type Polyline = LineSegment[]; export type Polycurve = Curve[]; export type Ellipse = { center: Point; angle: Radians; halfWidth: number; halfHeight: number; }; export type GeometricShape = { type: "line"; data: LineSegment; } | { type: "polygon"; data: Polygon; } | { type: "curve"; data: Curve; } | { type: "ellipse"; data: Ellipse; } | { type: "polyline"; data: Polyline; } | { type: "polycurve"; data: Polycurve; }; type RectangularElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement; export declare const getPolygonShape: (element: RectangularElement) => GeometricShape; export declare const getSelectionBoxShape: (element: ExcalidrawElement, elementsMap: ElementsMap, padding?: number) => GeometricShape; export declare const getEllipseShape: (element: ExcalidrawEllipseElement) => GeometricShape; export declare const getCurvePathOps: (shape: Drawable) => Op[]; export declare const getCurveShape: (roughShape: Drawable, startingPoint: Point | undefined, angleInRadian: Radians, center: Point) => GeometricShape; export declare const getFreedrawShape: (element: ExcalidrawFreeDrawElement, center: Point, isClosed?: boolean) => GeometricShape; export declare const getClosedCurveShape: (element: ExcalidrawLinearElement, roughShape: Drawable, startingPoint: Point | undefined, angleInRadian: Radians, center: Point) => GeometricShape; /** * Determine intersection of a rectangular shaped element and a * line segment. * * @param element The rectangular element to test against * @param segment The segment intersecting the element * @param gap Optional value to inflate the shape before testing * @returns An array of intersections */ export declare const segmentIntersectRectangleElement: (element: ExcalidrawBindableElement, segment: LineSegment, gap?: number) => Point[]; export declare const pointOnEllipse: (point: Point, ellipse: Ellipse, threshold?: number) => boolean; export declare const pointInEllipse: (p: Point, ellipse: Ellipse) => boolean; export declare const ellipseAxes: (ellipse: Ellipse) => { majorAxis: number; minorAxis: number; }; export declare const ellipseFocusToCenter: (ellipse: Ellipse) => number; export declare const ellipseExtremes: (ellipse: Ellipse) => import("@excalidraw/math").Vector[]; export {};