Home > SCH_PrimitiveArc > create
SCH_PrimitiveArc.create() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
创建圆弧
签名
typescript
function create(
startX: number,
startY: number,
referenceX: number,
referenceY: number,
endX: number,
endY: number,
color?: string | null,
fillColor?: string | null,
lineWidth?: number | null,
lineType?: ESCH_PrimitiveLineType | null,
): Promise<ISCH_PrimitiveArc | undefined>;1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
参数名
参数 | 类型 | 描述 |
|---|---|---|
startX | number | 起始点 X |
startY | number | 起始点 Y |
referenceX | number | 参考点 X |
referenceY | number | 参考点 Y |
endX | number | 终止点 X |
endY | number | 终止点 Y |
color | string | null | (可选) 颜色, |
fillColor | string | null | (可选) 填充颜色, |
lineWidth | number | null | (可选) 线宽,范围 |
lineType | ESCH_PrimitiveLineType | null | (可选) 线型, |
返回值
Promise<ISCH_PrimitiveArc | undefined>
圆弧图元对象
示例
javascript
// 1. 生成随机起点坐标,避免与画布上已有的圆弧重合(SCH 坐标单位 10mil)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
// 2. 创建一段红色虚线圆弧:起点(x, y),参考点(x+100, y+100),终点(x+200, y),线宽 6
const arc = await eda.sch_PrimitiveArc.create(x, y, x + 100, y + 100, x + 200, y, '#FF0000', null, 6, 1);
// 3. 创建类保留现场,不删除图元
console.log('primitiveId:', arc.getState_PrimitiveId());
console.log('primitiveType:', arc.getState_PrimitiveType());
console.log('startX:', arc.getState_StartX(), 'startY:', arc.getState_StartY());
console.log('referenceX:', arc.getState_ReferenceX(), 'referenceY:', arc.getState_ReferenceY());
console.log('endX:', arc.getState_EndX(), 'endY:', arc.getState_EndY());
console.log('color:', arc.getState_Color());
console.log('lineWidth:', arc.getState_LineWidth());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15