Home > PCB_PrimitiveImage > create
PCB_PrimitiveImage.create() method
Create Image
Signature
function create(
x: number,
y: number,
complexPolygon:
| TPCB_PolygonSourceArray
| Array<TPCB_PolygonSourceArray>
| IPCB_Polygon
| IPCB_ComplexPolygon,
layer: TPCB_LayersOfImage,
width?: number,
height?: number,
rotation?: number,
horizonMirror?: boolean,
primitiveLock?: boolean,
): Promise<IPCB_PrimitiveImage | undefined>;2
3
4
5
6
7
8
9
10
11
12
13
14
15
Parameters
Parameter | Type | Description |
|---|---|---|
x | number | BBox top-left point coordinates X |
y | number | BBox top-left point coordinates Y |
complexPolygon | TPCB_PolygonSourceArray | Array<TPCB_PolygonSourceArray> | IPCB_Polygon | IPCB_ComplexPolygon | Image source data (complex polygon). You can use the PCB_MathPolygon.convertImageToComplexPolygon() method to convert an image file into complex polygon data |
layer | Layer | |
width | number | (Optional) Width |
height | number | (Optional) Height |
rotation | number | (Optional) Rotation angle |
horizonMirror | boolean | (Optional) Whether it is horizontally mirrored |
primitiveLock | boolean | (Optional) Whether it is locked |
Returns
Promise<IPCB_PrimitiveImage | undefined>
Image primitive object
Remarks
To create a color silkscreen image, use the binary embedded object primitive class
Example
// 1. 生成随机基准坐标,避免与画布上已有的图像重合
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
// 2. 构造折线多边形轮廓(局部坐标 200×150 的五边形),图像轮廓必须是 ComplexPolygon 对象
const complexPolygon = eda.pcb_MathPolygon.createComplexPolygon([
0,
0,
'L',
200,
0,
200,
150,
100,
220,
0,
150
]);
// 3. 在顶层铜层(1)创建图像,宽 400、高 300,不旋转、不镜像、不锁定
const image = await eda.pcb_PrimitiveImage.create(x, y, complexPolygon, 1, 400, 300, 0, false, false);
// 4. 创建类保留现场,不删除图元
console.log('primitiveId:', image.getState_PrimitiveId());
console.log('layer:', image.getState_Layer());
console.log('width:', image.getState_Width());
console.log('height:', image.getState_Height());
console.log('primitiveType:', image.getState_PrimitiveType());2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28