fabric-texture
Version:
This JavaScript library enables fast and efficient image distortion transformations using Canvas 2D.
56 lines (34 loc) • 787 B
Markdown
[**fabric-texture**](../../../../README.md)
***
# Function: calcFabricRelativeCoord()
> **calcFabricRelativeCoord**(`position`, `object`): `Point`
计算 Fabric.js 对象的相对坐标位置
将绝对坐标转换为相对于指定 Fabric.js 对象的局部坐标系中的坐标。
考虑了对象的变换(如缩放、旋转、平移等)和特殊对象(如路径)的偏移。
## Parameters
### position
要转换的位置
#### left?
`number`
#### top?
`number`
### object
`Object`
Fabric.js 对象
## Returns
`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
);
```