Home > SCH_PrimitiveCircle > create
SCH_PrimitiveCircle.create() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
创建圆
签名
typescript
function create(
centerX: number,
centerY: number,
radius: number,
color?: string | null,
fillColor?: string | null,
lineWidth?: number | null,
lineType?: ESCH_PrimitiveLineType | null,
fillStyle?: ESCH_PrimitiveFillStyle | null,
): Promise<ISCH_PrimitiveCircle | undefined>;1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
参数名
参数 | 类型 | 描述 |
|---|---|---|
centerX | number | 圆心 X |
centerY | number | 圆心 Y |
radius | number | 半径 |
color | string | null | (可选) 颜色, |
fillColor | string | null | (可选) 填充颜色, |
lineWidth | number | null | (可选) 线宽,范围 |
lineType | ESCH_PrimitiveLineType | null | (可选) 线型, |
fillStyle | ESCH_PrimitiveFillStyle | null | (可选) 填充样式, |
返回值
Promise<ISCH_PrimitiveCircle | undefined>
圆图元对象
示例
javascript
// 1. 生成随机圆心坐标,避免与画布上已有的圆重合(SCH 坐标单位 10mil)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
// 2. 创建一个红色虚线边框、绿色网格填充的圆
const circle = await eda.sch_PrimitiveCircle.create(
x, // 圆心 X
y, // 圆心 Y
150, // 半径
'#FF0000', // 边框颜色
'#00FF00', // 填充颜色('none' 表示无填充)
6, // 线宽(范围 1-10)
1, // 线型:1 = DASHED(虚线)
'Grid' // 填充样式('Solid'/'Grid' 等字符串枚举)
);
// 3. 创建类保留现场,不删除图元
console.log('primitiveId:', circle.getState_PrimitiveId());
console.log('primitiveType:', circle.getState_PrimitiveType());
console.log('center:', circle.getState_CenterX(), ',', circle.getState_CenterY());
console.log('radius:', circle.getState_Radius());
console.log('color:', circle.getState_Color());
console.log('fillStyle:', circle.getState_FillStyle());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23