Home > SCH_PrimitiveCircle > create
SCH_PrimitiveCircle.create() 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.
Create a circle
Signature
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>;2
3
4
5
6
7
8
9
10
Parameters
Parameter | Type | Description |
|---|---|---|
centerX | number | Center of the circle X |
centerY | number | Center of the circle Y |
radius | number | Radius |
color | string | null | (Optional) Color, |
fillColor | string | null | (Optional) Fill color. |
lineWidth | number | null | (Optional) Line width, range |
lineType | ESCH_PrimitiveLineType | null | (Optional) Line type. |
fillStyle | ESCH_PrimitiveFillStyle | null | (Optional) Fill style, |
Returns
Promise<ISCH_PrimitiveCircle | undefined>
Circle primitive object
Example
// 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());2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23