Documentation Index
Fetch the complete documentation index at: https://docs.supernote.com/llms.txt
Use this file to discover all available pages before exploring further.
调用该接口会将几何图形插入到当前打开文件当前页当前图层。
static insertGeometry(geometry: Geometry): Promise<APIResponse<boolean>>;
参数
| 参数 | 类型 | 说明 |
|---|
geometry | Geometry | 几何图形参数;可通过 showLassoAfterInsert 控制插入后是否自动显示套索状态 |
返回
import { PluginCommAPI, type Geometry } from 'sn-plugin-lib';
/**
* 插入一个简单几何图形的示例。
*/
export async function exampleInsertGeometry() {
const geometry: Geometry = {
showLassoAfterInsert: false,
penColor: 0x9d,
penType: 10,
penWidth: 200, // 最小值 100
type: 'GEO_polygon',
points: [
{ x: 100, y: 100 },
{ x: 200, y: 100 },
{ x: 200, y: 200 },
{ x: 100, y: 200 },
{ x: 100, y: 100 },
],
ellipseCenterPoint: null,
ellipseMajorAxisRadius: 0,
ellipseMinorAxisRadius: 0,
ellipseAngle: 0,
};
const res = await PluginCommAPI.insertGeometry(geometry);
if (!res.success) {
throw new Error(res.error?.message ?? 'insertGeometry 调用失败');
}
return res.result;
}