image-js
Version:
Image processing and manipulation in JavaScript
67 lines • 2.05 kB
TypeScript
/**
* Coordinates of a point in an image with the top-left corner being the reference point. The point is a [column, row] array.
*/
export type ArrayPoint = [column: number, row: number];
/**
* Coordinates of a point in an image with the top-left corner being the reference point.
*/
export interface Point {
/**
* Point row.
*
*/
row: number;
/**
* Point column.
*
*/
column: number;
}
/**
* Calculates a new point that is the difference p1 - p2.
* @param p1 - First point.
* @param p2 - Second Point.
* @returns Difference between the two points.
*/
export declare function difference(p1: Point, p2: Point): Point;
/**
* Calculates a new point that is the sum p1 + p2.
* @param p1 - First point.
* @param p2 - Second Point.
* @returns Sum of the two points.
*/
export declare function sum(p1: Point, p2: Point): Point;
/**
* Normalize a point (more precisely the vector from the origin to the point).
* @param point - Point to normalize.
* @returns - Normalized point.
*/
export declare function normalize(point: Point): Point;
/**
* Rotate an array of points by an angle in radians.
* The rotation is clockwise and the reference is (0,0).
* @param radians - Angle in radians.
* @param points - Source points.
* @returns The points after rotation.
*/
export declare function rotate(radians: number, points: readonly Point[]): Point[];
/**
* Dot product of 2 points assuming vectors starting from (0,0).
* @param p1 - First point.
* @param p2 - Second point.
* @returns Dot product between the two vectors.
*/
export declare function dot(p1: Point, p2: Point): number;
/**
* Round the coordinates of the point.
* @param point - The point.
* @returns Rounded coordinates of the point.
*/
export declare function round(point: Point): Point;
/**
* Sort an array of points by column then row.
* @param points - Array of points to sort.
* @returns Sorted points.
*/
export declare function sortByColumnRow(points: Point[]): Point[];
//# sourceMappingURL=points.d.ts.map