fabric-texture
Version:
This JavaScript library enables fast and efficient image distortion transformations using Canvas 2D.
60 lines (34 loc) • 923 B
Markdown
[**fabric-texture**](../../../../README.md)
***
# Function: calcBoundingBox()
> **calcBoundingBox**(`a`, `b`, `c`): `object`
计算三角形的最小包围盒(Bounding Box)
计算能完全包含三角形的最小矩形区域。
通过计算三个顶点的最大和最小坐标值来确定包围盒的尺寸。
## Parameters
### a
`Coord`
三角形的第一个顶点坐标 {x: number, y: number}
### b
`Coord`
三角形的第二个顶点坐标 {x: number, y: number}
### c
`Coord`
三角形的第三个顶点坐标 {x: number, y: number}
## Returns
`object`
包围盒的尺寸
### height
> **height**: `number`
### width
> **width**: `number`
## Example
```typescript
// 计算等边三角形的包围盒
const p1 = { x: 0, y: 0 };
const p2 = { x: 100, y: 0 };
const p3 = { x: 50, y: 86.6 };
const box = calcBoundingBox(p1, p2, p3);
console.log(box);
// 输出: { width: 100, height: 86.6 }
```