Home > PCB_MathPolygon > calculateWidth
PCB_MathPolygon.calculateWidth() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Calculate complex polygon BBox width
Signature
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
Parameters
Parameter | Type | Description |
|---|---|---|
complexPolygon | TPCB_PolygonSourceArray | Array<TPCB_PolygonSourceArray> | IPCB_Polygon | IPCB_ComplexPolygon | Complex polygon |
Returns
number
BBox width
Example
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