Home > PCB_MathPolygon > calculateWidth
PCB_MathPolygon.calculateWidth() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
计算复杂多边形 BBox 宽度
签名
typescript
function calculateWidth(
complexPolygon:
| TPCB_PolygonSourceArray
| Array<TPCB_PolygonSourceArray>
| IPCB_Polygon
| IPCB_ComplexPolygon,
): number;1
2
3
4
5
6
7
2
3
4
5
6
7
参数名
参数 | 类型 | 描述 |
|---|---|---|
complexPolygon | TPCB_PolygonSourceArray | Array<TPCB_PolygonSourceArray> | IPCB_Polygon | IPCB_ComplexPolygon | 复杂多边形 |
返回值
number
BBox 宽度
示例
javascript
// 1. 矩形源数组(宽 100、高 50),BBox 宽度为 100
console.log('rectWidth:', eda.pcb_MathPolygon.calculateWidth(['R', 0, 0, 100, 50, 0, 0]));
// 2. 圆心在原点、半径 50 的圆,BBox 宽度为直径 100
console.log('circleWidth:', eda.pcb_MathPolygon.calculateWidth(['CIRCLE', 0, 0, 50]));
// 3. 传复杂多边形对象:矩形 X 范围 0~100,圆 X 范围 170~230,整体跨度 230
const complexPolygon = eda.pcb_MathPolygon.createComplexPolygon([
['R', 0, 0, 100, 50, 0, 0],
['CIRCLE', 200, 200, 30],
]);
console.log('complexWidth:', eda.pcb_MathPolygon.calculateWidth(complexPolygon));1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12