UNPKG

ducjs

Version:

The duc 2D CAD file format is a cornerstone of our advanced design system, conceived to cater to professionals seeking precision and efficiency in their design work.

76 lines (75 loc) 3.6 kB
import { Scope, ScopedValue } from "../types"; import { DucElement, DucFreeDrawElement, DucLine, DucLinearElement, DucPoint, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap } from "../types/elements"; import { Bounds, GeometricPoint } from "../types/geometryTypes"; type SV = ScopedValue; /** * Common bounds calculation interface */ export interface BoundsResult { minX: ScopedValue; minY: ScopedValue; maxX: ScopedValue; maxY: ScopedValue; } /** * Extended bounds calculation interface with center coordinates */ export interface ExtendedBoundsResult extends BoundsResult { cx: ScopedValue; cy: ScopedValue; } export type ElementAbsoluteCoords = [SV, SV, SV, SV, SV, SV]; export declare const getElementAbsoluteCoords: (element: DucElement, elementsMap: ElementsMap, currentScope: Scope, includeBoundText?: boolean, returnUnrotatedBoundsOnly?: boolean) => ElementAbsoluteCoords; /** * Calculates bounds from a list of points (basic implementation) */ export declare const calculatePointsBounds: (points: readonly DucPoint[]) => BoundsResult; /** * Calculates bounds from a list of geometric points (for bounds.ts compatibility) */ export declare const calculateGeometricPointsBounds: (points: GeometricPoint[]) => BoundsResult; /** * Processes Bezier curves from lines and updates bounds */ export declare const processBezierCurveBounds: (points: readonly DucPoint[], lines: readonly DucLine[], initialBounds: BoundsResult) => BoundsResult; /** * Processes Bezier curves with rotation and absolute positioning * Used for linear elements that need to account for rotation and absolute coordinates */ export declare const processRotatedAbsoluteBezierBounds: (points: readonly DucPoint[], lines: readonly DucLine[], elementX: ScopedValue, elementY: ScopedValue, centerX: ScopedValue, centerY: ScopedValue, angle: number) => { minX: number; minY: number; maxX: number; maxY: number; }; /** * Processes Bezier curves without rotation (for relative coordinate systems) * Used by getElementPointsCoords */ export declare const processRelativeBezierBounds: (points: readonly DucPoint[], lines: readonly DucLine[], initialBounds: { minX: number; minY: number; maxX: number; maxY: number; }) => { minX: number; minY: number; maxX: number; maxY: number; }; /** * Calculates bounds considering both points and Bezier curves defined by lines */ export declare const calculateShapeBounds: (points: readonly DucPoint[], lines: readonly DucLine[]) => BoundsResult; /** * Extended bounds calculation that includes center coordinates */ export declare const calculatePointsBoundsWithCenter: (points: readonly DucPoint[]) => ExtendedBoundsResult; export declare const getElementPointsCoords: (element: DucLinearElement, points: readonly DucPoint[]) => Bounds; export declare const getContainerElement: (element: DucTextElement | null, elementsMap: ElementsMap) => DucTextContainer | null; export declare const getBoundsFromPoints: (points: GeometricPoint[]) => Bounds; export declare const getFreeDrawElementAbsoluteCoords: (element: DucFreeDrawElement) => ElementAbsoluteCoords; export declare const getBoundTextElementId: (container: DucElement | null) => string | null; export declare const getBoundTextElement: (element: DucElement | null, elementsMap: ElementsMap) => DucTextElementWithContainer | null; export declare const getResizedElementAbsoluteCoords: (element: DucElement, nextWidth: ScopedValue, nextHeight: ScopedValue, normalizePoints: boolean, currentScope: Scope) => Bounds; export {};