Import these from @grafloria/engine.
Functions
boxesIntersect
Check if two bounding boxes intersect
tsfunction boxesIntersect(box1: BoundingBox, box2: BoundingBox): boolean
clampToBox
Clamp point to bounding box
tsfunction clampToBox(point: Point, box: BoundingBox): Point
createBoundingBox
Create bounding box from position and size
tsfunction createBoundingBox(
position: Point,
size: Size
): BoundingBox
deepClone
Deep clone an object with circular reference handling Handles dates, arrays, maps, sets, plain objects, and circular references
tsfunction deepClone<T>(value: T, visited: WeakMap<any, any> = new WeakMap()): T
deepEqual
Check if two values are deeply equal
tsfunction deepEqual(a: any, b: any): boolean
distance
Calculate distance between two points
tsfunction distance(p1: Point, p2: Point): number
expandBox
Expand bounding box by margin
tsfunction expandBox(box: BoundingBox, margin: number): BoundingBox
generateId
Generate a short unique ID (12 characters) Used for internal references
tsfunction generateId(): string
generatePrefixedId
Generate a prefixed ID
tsfunction generatePrefixedId(prefix: string): string
generateUUID
Generate a UUID Used for persistent identifiers
tsfunction generateUUID(): string
isPointInShape
Determine if a point is inside a shape Returns true if point (px, py) is within the shape defined by bounds and shapeConfig
Shape-aware hit detection for accurate mouse interactions
tsfunction isPointInShape(
px: number,
py: number,
bounds: BoundingBox,
shapeConfig?: ShapeConfig
): boolean
isValidId
Validate if string is a valid ID format
tsfunction isValidId(id: string): boolean
isValidUUID
Validate if string is a valid UUID format
tsfunction isValidUUID(uuid: string): boolean
midpoint
Calculate midpoint between two points
tsfunction midpoint(p1: Point, p2: Point): Point
pointInBox
Check if point is inside bounding box
tsfunction pointInBox(point: Point, box: BoundingBox): boolean
rotatePoint
Rotate point around origin
tsfunction rotatePoint(
point: Point,
origin: Point,
angle: number
): Point
scalePoint
Scale point from origin
tsfunction scalePoint(
point: Point,
origin: Point,
scale: Point
): Point
Was this page helpful?