import { PluginCommAPI, type Element } from 'sn-plugin-lib';
/**
* 将套索选中的元素转换为贴纸的示例。
*/
export async function exampleConvertElement2Sticker() {
const lassoRes = await PluginCommAPI.getLassoElements();
if (!lassoRes.success) {
throw new Error(lassoRes.error?.message ?? 'getLassoElements 调用失败');
}
const params = {
machineType: 3,
elements: (lassoRes.result ?? []) as Element[],
stickerPath: '/storage/emulated/0/Note/stickers/out.png',
};
const res = await PluginCommAPI.convertElement2Sticker(params as any);
if (!res.success) {
throw new Error(res.error?.message ?? 'convertElement2Sticker 调用失败');
}
return res.result;
}