ngx-diagrams
Version:
> Light Weight, Modular, Typed Diagram Engine for Angular
48 lines (47 loc) • 1.45 kB
TypeScript
import { DiagramEngine } from '../services/engine.service';
import * as PF from 'pathfinding';
export declare const ROUTING_SCALING_FACTOR = 10;
export declare class PathFinding {
private diagramEngine;
private pathFinderInstance;
constructor(diagramEngine: DiagramEngine, heuristic?: typeof PF.Heuristic.manhattan);
/**
* Taking as argument a fully unblocked walking matrix, this method
* finds a direct path from point A to B.
*/
calculateDirectPath(from: {
x: number;
y: number;
}, to: {
x: number;
y: number;
}): number[][];
/**
* Using @link{#calculateDirectPath}'s result as input, we here
* determine the first walkable point found in the matrix that includes
* blocked paths.
*/
calculateLinkStartEndCoords(matrix: number[][], path: number[][]): {
start: {
x: number;
y: number;
};
end: {
x: number;
y: number;
};
pathToStart: number[][];
pathToEnd: number[][];
};
/**
* Puts everything together: merges the paths from/to the centre of the ports,
* with the path calculated around other elements.
*/
calculateDynamicPath(routingMatrix: number[][], start: {
x: number;
y: number;
}, end: {
x: number;
y: number;
}, pathToStart: number[][], pathToEnd: number[][]): number[][];
}