warpvas
Version:
This JavaScript library enables fast and efficient image distortion transformations using Canvas 2D.
27 lines (26 loc) • 839 B
TypeScript
/**
* Calculate coordinates along a line at specified distance
*
* @param p0 - Start point coordinates {x: number, y: number}
* @param p1 - Direction reference point coordinates
* @param value - Distance to move (positive: towards p1, negative: opposite)
*
* @returns New coordinates along the line segment
*
* @example
* ```typescript
* // Horizontal movement
* const start = { x: 0, y: 0 };
* const end = { x: 10, y: 0 };
* console.log(calcRelativeCoord(start, end, 5)); // {x:5, y:0}
*
* // Diagonal movement
* console.log(calcRelativeCoord(start, {x:3,y:4}, 5)); // {x:3, y:4}
* ```
*
* @remarks
* - Returns p0 when points coincide
* - Handles vertical/horizontal/sloped lines
* - Subject to JS floating-point precision
*/
export declare const calcRelativeCoord: (p0: Coord, p1: Coord, value: number) => Coord;