UNPKG

@orca-fe/transformer

Version:
74 lines (73 loc) 2.13 kB
import { mat3 } from 'gl-matrix'; export type ResizeType = 'keyboard' | 'rotate' | 'move' | 'top' | 'left' | 'bottom' | 'right' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight'; export type Bounds = { top: number; left: number; width: number; height: number; rotate?: number; }; export type Point = { x: number; y: number; }; export declare function getResizeMode(classList: string[]): ResizeType; export type CalcPropsChangeOptions = { resizeType?: ResizeType; eqRatio?: boolean; symmetrical?: boolean; }; export declare function rad(degrees: number): number; export declare function deg(radians: number): number; /** * 获取变换信息(位置和旋转) * @param matrix 变换矩阵 * @returns { x: number; y: number; rotate: number } 变换信息 */ export declare function getTransformInfo(matrix: mat3): { x: number; y: number; rotate: number; }; /** * 计算 bounds 的变化 * @param startBounds 原始 bounds * @param pointOffset 鼠标偏移 * @param options */ export declare function calcBoundsChange(startBounds: Bounds, pointOffset: Point, options?: CalcPropsChangeOptions): { left: number; top: number; rotate?: undefined; } | { left: number; top: number; rotate: number; } | { left: number; top: number; width: number; height: number; rotate?: number | undefined; }; /** * 判断 bounds 的中心点是否在 limit 内,如果不是,则生成符合限制的新 bounds * @param bounds * @param limit */ export declare function calcLimitBounds(bounds: Bounds, limit?: Bounds): Bounds; /** * 计算 bounds 的变化 * @param startBounds 原始 bounds * @param pointOffset 鼠标偏移 * @param options */ export declare const calcBoundsChangeBack: (startBounds: Bounds, _currentPoint: Point, pointOffset: Point, options?: CalcPropsChangeOptions) => Partial<Bounds>; export declare const getPointByEvent: (event: PointerEvent | MouseEvent | TouchEvent) => { x: number; y: number; }; export declare const getPointOffset: (p1: Point, p2: Point) => { x: number; y: number; };