图形如何导出和导入?
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 230
- PR merge metrics
- No merged PRs in 30d
Description
我画了一个几个简单的图形,怎么把这个图形数据保存,以便下次进入画布的时候直接显示上次画的图形?
我需要有2个方法,类似下面这种:
```ts
const node1 = new Circle({
style: {
r: 100, // 半径
fill: '#1890FF', // 填充色
stroke: '#F04864', // 描边颜色
lineWidth: 4, // 描边宽度
},
});
node1.setPosition(200, 200);
const last = await node1.toObject();
// ....
const node = await canvas.loadObject(last);
canvas.appendChild(node);
```
Contributor guide
Research direction
Start from the Circle example and the canvas entry points named in the issue: node1.toObject() and canvas.loadObject(last). Define the serialization and restoration behavior for a simple shape, then verify that the loaded object can be appended and displays the saved geometry and styles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100