简体中文
Home > PNL_PrimitiveRectangle > create
PNL_PrimitiveRectangle.create() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
创建矩形图元
签名
typescript
function create(
params: IPNL_RectangleCreateParameters,
): Promise<IPNL_PrimitiveRectangle | undefined>;1
2
3
2
3
参数名
参数 | 类型 | 描述 |
|---|---|---|
params | 矩形创建参数,见 IPNL_RectangleCreateParameters |
返回值
Promise<IPNL_PrimitiveRectangle | undefined>
创建的矩形图元对象,创建失败抛出中文错误
备注
坐标为笛卡尔坐标系(Y 轴向上为正),x / y 为矩形参考点位置,参考点缺省为左下角,rotation 为 0 时即包围盒左下角
rotation 为绕参考点逆时针旋转的角度(度),旋转时参考点保持不动
例:{ x: 0, y: 150, width: 180, height: 90 } 表示左下角在原点上方 150、左上角在原点上方 240
ADD since EDA v4.1.105
示例
javascript
// 1. 创建直角矩形(左下角在原点上方 100)
const rect = await eda.pnl_PrimitiveRectangle.create({ x: 100, y: 100, width: 200, height: 120 });
// 2. 创建圆角矩形 + 自定义样式
const rounded = await eda.pnl_PrimitiveRectangle.create({
x: 400,
y: 100,
width: 160,
height: 160,
rx: 20,
ry: 20,
strokeColor: '#FF6600',
fillColor: '#FFEE00',
strokeWidth: 3,
});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