[**fabric-texture**](../../../../README.md)

***

# Function: calcRelativeCoord()

> **calcRelativeCoord**(`p0`, `p1`, `value`): `Coord`

在直线上计算特定距离的点坐标

在由两点确定的直线上，从起点出发计算特定距离处的点坐标。
该函数处理了以下情况：
1. 两点重合的特殊情况
2. 垂直于坐标轴的直线
3. 水平于坐标轴的直线
4. 一般斜线情况

## Parameters

### p0

`Coord`

起点坐标

### p1

`Coord`

方向参考点坐标

### value

`number`

目标距离
  - 正值：向 p1 方向移动
  - 负值：向 p1 相反方向移动
  - 零值：返回起点坐标

## Returns

`Coord`

计算得到的新坐标点

## Example

```typescript
// 在水平线上移动
const start = { x: 0, y: 0 };
const direction = { x: 10, y: 0 };

// 向右移动5个单位
const point1 = calcRelativeCoord(start, direction, 5);
console.log(point1); // { x: 5, y: 0 }

// 向左移动3个单位
const point2 = calcRelativeCoord(start, direction, -3);
console.log(point2); // { x: -3, y: 0 }

// 在斜线上移动
const diagonal = { x: 3, y: 4 };
const point3 = calcRelativeCoord(start, diagonal, 5);
// 返回在斜线方向上距离为5的点
```

## Remarks

- 如果两点重合，返回起点坐标
- 支持任意方向的直线
- 计算结果精度受 JavaScript 浮点数精度限制
