UNPKG

fabric-texture

Version:

This JavaScript library enables fast and efficient image distortion transformations using Canvas 2D.

36 lines (35 loc) 959 B
import { fabric } from 'fabric'; /** * 计算 Fabric.js 对象的相对坐标位置 * * 将绝对坐标转换为相对于指定 Fabric.js 对象的局部坐标系中的坐标。 * 考虑了对象的变换(如缩放、旋转、平移等)和特殊对象(如路径)的偏移。 * * @param position - 要转换的位置 * @property {number} [left=0] - 相对于画布左边的距离 * @property {number} [top=0] - 相对于画布顶部的距离 * * @param object - Fabric.js 对象 * * @returns {fabric.Point} 转换后的相对坐标点 * * @example * ```typescript * const rect = new fabric.Rect({ * left: 100, * top: 100, * width: 50, * height: 50, * angle: 45 * }); * * const relativePoint = calcFabricRelativeCoord( * { left: 120, top: 120 }, * rect * ); * ``` */ export declare const calcFabricRelativeCoord: (position: { left?: number; top?: number; }, object: fabric.Object) => fabric.Point;