import { Side } from './svg-util'; /** * A point on a canvas defined as its coordinates along the x and y axes. * @public * @see DiagramCanvas */ export type Point = [number, number]; /** * A line on a canvas defined as its start point and end point. * @public * @see DiagramCanvas */ export type Line = [Point, Point]; /** * A rectangle on a canvas defined as the points of its opposite corners. * @public * @see DiagramCanvas */ export type Rectangle = [Point, Point]; /** * Round the coordinates of the given point to the nearest whole number. * @public * @param point A point. * @returns A new point with whole coordinates. */ export declare const roundPoint: (point: Point) => Point; /** * Checks if the given coordinate is in the range given by an starting coordinate and an ending coordinate. * @public * @param coordinate A coordinate to check its presence in the range. * @param start A coordinate determining one of the extremes in the range. * @param end A coordinate determine one of the extremes in the range. * @returns `true` if the given coordinate is in the given range; `false` otherwise. */ export declare const isBetweenCoordinates: (coordinate: number, start: number, end: number) => boolean; /** * Moves the given coordinate according to the given changes in coordinates. * @public * @param oldCoordinate A coordinate. * @param oldCoordinates A range of coordinates. * @param newCoordinates A range of coordinates. * @returns A new coordinate. */ export declare const translateCoordinate: (oldCoordinate: number, oldCoordinates: [number, number], newCoordinates: [number, number]) => number; /** * Moves the coordinates of the given point according to the given changes in coordinates. * @public * @param oldPoint A point. * @param oldCoordsX A range of coordinates along the x axis. * @param oldCoordsY A range of coordinates along the y axis. * @param newCoordsX A range of coordinates along the x axis. * @param newCoordsY A range of coordinates along the y axis. * @returns A new point. */ export declare const translatePoint: (oldPoint: Point, oldCoordsX: [number, number], oldCoordsY: [number, number], newCoordsX: [number, number], newCoordsY: [number, number]) => Point; /** * Types of anchor points for ports and decorators. * @public */ export type AnchorPoint = 'start' | 'middle' | 'end' | 'floating'; /** * Moves the coordinates of the given point according to the given changes in coordinates and anchor points. * @public * @param oldPoint A point. * @param oldCoordsX A range of coordinates along the x axis. * @param oldCoordsY A range of coordinates along the y axis. * @param newCoordsX A range of coordinates along the x axis. * @param newCoordsY A range of coordinates along the y axis. * @param anchorPointX The horizontal anchor point behavior. * @param anchorPointY The vertical anchor point behavior. * @returns A new point. */ export declare const translatePointWithAnchors: (oldPoint: Point, oldCoordsX: [number, number], oldCoordsY: [number, number], newCoordsX: [number, number], newCoordsY: [number, number], anchorPointX: AnchorPoint, anchorPointY: AnchorPoint) => Point; /** * Calculates the result of moving the given point by the given distance in the given direction. * @public * @param point A point. * @param direction A direction. * @param distance A distance. * @returns A new point which differs from the given point by the given distance in the given direction. */ export declare const movePoint: (point: Point, direction: Side, distance: number) => Point; /** * Checks whether two given points are the same point, that is, they have the same coordinates and are not NaN. * @public * @param point1 A point. * @param point2 A point. * @returns `true` if the two points have the same coordinates; `false` otherwise. */ export declare const pointsEqual: (point1: Point, point2: Point) => boolean; /** * Calculates the euclidean distance between two points. * @public * @param point1 A point. * @param point2 A point. * @returns The euclidean distance between the given points. */ export declare const distanceBetweenPoints: (point1: Point, point2: Point) => number; /** * Calculates the slope of the line as the ratio between the increase of the second coordinate and the increase of the first coordinate. * @public * @param line A line. * @returns The ratio between the increase of the second coordinate and the increase of the first coordinate. `Infinity` if the increase of the first coordiante is zero. `NaN` if the line is a point. */ export declare const slope: (line: Line) => number; /** * Checks whether the given point is inside the given line. * @public * @param line A line. * @param point A point. * @returns `true` if the point is contained within the line; `false` otherwise. */ export declare const lineContainsPoint: (line: Line, point: Point) => boolean; /** * Checks whether the given point is inside the given rectaingle. * @public * @param rectangle A rectangle. * @param point A point. * @returns `true` if the point is contained within the rectangle; `false` otherwise. */ export declare const rectangleContainsPoint: (rectangle: Rectangle, point: Point) => boolean; /** * Checks whether the two given lines share at least one point. * @public * @param line1 A line. * @param line2 A line. * @returns `true` if the lines intersect; `false` otherwise. */ export declare const linesIntersect: (line1: Line, line2: Line) => boolean; /** * Checks whether the two given lines share at least one point and have the same slope. * @public * @param line1 A line. * @param line2 A line. * @returns `true` if the lines overlap; `false` otherwise. */ export declare const linesOverlap: (line1: Line, line2: Line) => boolean; /** * Checks whether the given line shares at least one point with the given rectangle. * @public * @param line A line. * @param rectangle A rectangle. * @returns `true` if the line intersects with the rectangle; `false` otherwise. */ export declare const lineIntersectsRectangle: (line: Line, rectangle: Rectangle) => boolean; /** * Checks whether the two given rectangles share at least one point. * @public * @param rectangle1 A rectangle. * @param rectangle2 A rectangle. * @returns `true` if the rectangles intersect; `false` otherwise. */ export declare const rectanglesIntersect: (rectangle1: Rectangle, rectangle2: Rectangle) => boolean;