UNPKG

mskalign-canvas

Version:

一个用于图片标注的javascript库,基于canvas,简单轻量,支持矩形、多边形、点、折线、圆形。

87 lines (86 loc) 3.58 kB
import type { Point, OffsetPoint, WH, RememberPointsType } from '../types'; import type { AllShape } from '../index'; export declare function sortByHeightPoint(coorData: AllShape[], isSort?: boolean, dataType?: string): AllShape[]; /** * 根据两点求出垂线过第三点的直线的交点 * @ param pt1 直线上的第一个点 * @ param pt2 直线上的第二个点 * @ param pt3 垂线上的点(当前鼠标的点) * @ return 返回点到直线的垂直交点坐标的延长线 */ export declare function crossCor(pt1: Point, pt2: Point, pt3: Point, length: number): number[]; export declare function getMiddlePoint(points: Point[], scale?: number): Point; /** * @description: 计算两条线的夹角 * @param {*} point1 line1的起点坐标 * @param {*} point2 line1的终点坐标 * @param {*} point3 line2的起点坐标 * @param {*} point4 line2的终点坐标 * @return {*} */ export declare function getTwoLineAngle([point1, point2, point3, point4]: Point[]): number; /** * @description: 获取一个点到一条线的垂直像素距离和垂直点坐标 * @param {*} point1 直线的起点坐标 * @param {*} point2 直线的终点坐标 * @param {*} point3 点的坐标 * @return {*} */ export declare function getDistanceP2L(point1: Point, point2: Point, point3: Point): { distance: number; pedal: { x: number; y: number; }; }; /** * @description: 获取两点之间的像素距离 * @param {*} point1 点1 * @param {*} point2 点2 * @return {*} 像素距离 */ export declare function getTwoPointDistance(point1: Point, point2: Point): number; /** * @description: 四边形的对角线中心点 * @param {*} point1 * @param {*} point3 * @param {*} point2 * @param {*} point4 * @return {*} 对角线中心点 */ export declare function getQuadrilateralCenter(point1: Point, point2: Point, point4: Point, point3: Point): false | { x: number; y: number; }; export declare function adjustBrightnessLinear(imageData: any, brightnessFactor: number): any; export declare function changeLuminance(imgData: any, value: number): any; /** * 修改亮度 */ export declare function rgb2hsv(arr: number[]): number[]; export declare function hsv2rgb(hsv: number[]): number[]; export declare function getNewCoor(activeShape: AllShape, { offsetX, offsetY }: OffsetPoint, { w, h }: WH, remember: RememberPointsType): any; /** * 判断是否在椭圆内 * @param targetPoint 坐标 * @param centerPoint 圆心 * @param radiusX 长半径 * @param radiusY 短半径 * @param rotation 旋转角度 * @returns 布尔值 */ export declare const isPointInRotatedEllipse: (targetPoint: Point, centerPoint: Point, radiusX: number, radiusY: number, rotation: number, { originX, originY, scale, creating }: any) => boolean; /** * 判断是否在圆内 * @param point 坐标 * @param center 圆心 * @param r 半径 * @param needScale 是否为圆形点击检测 * @creating 是否为创建中 * @returns 布尔值 */ export declare const isPointInCircle: (point: Point, center: Point, r: number, { originX, originY, scale, creating }: any) => boolean; export declare const calculateRotation: (targetPoint: Point, centerPoint: Point) => number; export declare const rotatePoint: (centerPoint: Point, theta: number, targetPoint: Point) => Point; export declare function getEllipseEndpoints(centerPoint: Point, rotation: number, points: Point[]): Point[]; export declare const getRealAngle: (rotation: number) => number;