Home > IPCB_PrimitiveImage > toAsync
IPCB_PrimitiveImage.toAsync() method
将图元转换为异步图元
签名
typescript
function toAsync(): IPCB_PrimitiveImage;1
返回值
图像图元对象
示例
javascript
// 1. 生成本次运行专用的坐标,创建一个 400 x 300 的顶层图像
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
const complexPolygon = eda.pcb_MathPolygon.createComplexPolygon([0, 0, 'L', 200, 0, 200, 150, 0, 150]);
const image = await eda.pcb_PrimitiveImage.create(x, y, complexPolygon, 1, 400, 300, 0, false, false);
// 2. 切换异步模式后批量修改:放大到 600 x 450
const asyncImage = image.toAsync();
asyncImage.setState_Width(600);
asyncImage.setState_Height(450);
await asyncImage.done();
// 3. 从画布重新读取,确认批量修改已生效(保留现场供观察)
const refetched = await eda.pcb_PrimitiveImage.get(image.getState_PrimitiveId());
console.log('width:', refetched.getState_Width());
console.log('height:', refetched.getState_Height());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17