ice-render 0.0.47 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -7
- package/dist/index.cjs.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/graphic/ICEComponent.d.ts +9 -2
- package/dist/types/graphic/link/ICELinkSlot.d.ts +6 -5
- package/dist/types/graphic/link/ICELinkSlotManager.d.ts +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,17 +4,136 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">ICERender - 雪花渲染器</h1>
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 1.简介
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
ICERender 是一款 canvas 渲染引擎。
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## 2.核心特性
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
- 只依赖 loadash 和 gl-matrix 两个库,无其它依赖。
|
|
14
|
+
- 纯 TypeScript 代码。
|
|
15
|
+
- 纯 OO 结构,逻辑结构清晰,可持续演进。
|
|
16
|
+
- 支持鼠标和键盘事件。
|
|
17
|
+
- 图形对象可以形成无限嵌套结构。
|
|
18
|
+
- 整张图可以序列化成 JSON 字符串,可以从 JSON 字符串反序列化成图形。
|
|
19
|
+
- 支持动画,动画配置方式类似 CSS 的 keyframes 语法。
|
|
20
|
+
- 支持 Visio 形态的连接线。
|
|
21
|
+
- 性能优异,同一张图 2000 个可交互图元,顺畅无卡顿。
|
|
14
22
|
|
|
15
|
-
##
|
|
23
|
+
## 3.用法
|
|
16
24
|
|
|
17
|
-
|
|
25
|
+
ice-render 有3个版本的发布包: esm/cjs/umd ,可以在浏览器中直接引用,也可以基于 ES 版本进行二次开发,也可以在 NodeJS 环境中使用。
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
### 3.1 直接在浏览器中使用
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
|
|
31
|
+
<script src="../dist/index.umd.js"></script>
|
|
32
|
+
|
|
33
|
+
<canvas id="canvas-1" width="1024" height="768" style="background-color: #f7f7f7;"></canvas>
|
|
34
|
+
|
|
35
|
+
let ice = new ICE.ICE().init('canvas-1');
|
|
36
|
+
|
|
37
|
+
let rect = new ICE.ICERect({
|
|
38
|
+
left: 1024 * Math.random(),
|
|
39
|
+
top: 768 * Math.random(),
|
|
40
|
+
width:50,
|
|
41
|
+
height:50,
|
|
42
|
+
style:{
|
|
43
|
+
strokeStyle:'#ff3300',
|
|
44
|
+
fillStyle:'#00ff00',
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
ice.addChild(rect);
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
在此项目的 /test 目录下,提供了大量直接在浏览器中使用的例子,请参考: https://github.com/ice-render/ice-render
|
|
52
|
+
|
|
53
|
+
### 3.2 二次开发
|
|
54
|
+
|
|
55
|
+
在你的项目中安装依赖:
|
|
56
|
+
|
|
57
|
+
```shell
|
|
58
|
+
npm i ice-render --save
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
基于 ice-render 提供的类和接口二次开发,示例:
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
import { ICEVisioLink } from 'ice-render';
|
|
65
|
+
|
|
66
|
+
export default class Relation extends ICEVisioLink {
|
|
67
|
+
constructor(props) {
|
|
68
|
+
super({
|
|
69
|
+
title: 'Relation',
|
|
70
|
+
relationType: 'one-to-one',
|
|
71
|
+
referencedColumnName: 'id',
|
|
72
|
+
...props,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 实体类的 JSON 格式描述,与 type-orm 规定的格式对应
|
|
78
|
+
*/
|
|
79
|
+
public toEntityObject(): any {
|
|
80
|
+
let { title, relationType, referencedColumnName } = this.state;
|
|
81
|
+
let fromComponent, toComponent, fromId, fromName, toId, toName;
|
|
82
|
+
if (this.state.links && this.state.links.start && this.state.links.start.id) {
|
|
83
|
+
fromId = this.state.links.start.id;
|
|
84
|
+
fromComponent = this.ice.findComponent(fromId);
|
|
85
|
+
fromName = fromComponent.state.entityName;
|
|
86
|
+
}
|
|
87
|
+
if (this.state.links && this.state.links.end && this.state.links.end.id) {
|
|
88
|
+
toId = this.state.links.end.id;
|
|
89
|
+
toComponent = this.ice.findComponent(toId);
|
|
90
|
+
toName = toComponent.state.entityName;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let result = {
|
|
94
|
+
title,
|
|
95
|
+
fromId,
|
|
96
|
+
fromName,
|
|
97
|
+
toId,
|
|
98
|
+
toName,
|
|
99
|
+
relationType,
|
|
100
|
+
referencedColumnName,
|
|
101
|
+
};
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
ice-entity-designer 是一款基于 ice-render 开发的 ER 设计器,完整示范了如何基于 ice-render 引擎进行二次开发, https://github.com/ice-render/ice-entity-designer 。
|
|
109
|
+
|
|
110
|
+
ice-entity-designer 已经用在了 craft-codeless-designer 低代码项目中, https://github.com/craft-codeless-designer 。
|
|
111
|
+
|
|
112
|
+
<img src="./tests/assets/11.png">
|
|
113
|
+
|
|
114
|
+
如需更详细的架构文档,请联系我。
|
|
115
|
+
|
|
116
|
+
### 3.3 在 NodeJS 环境中使用
|
|
117
|
+
|
|
118
|
+
【待测试】
|
|
119
|
+
|
|
120
|
+
## 4.截图
|
|
121
|
+
|
|
122
|
+
<img src="./tests/assets/1.png">
|
|
123
|
+
|
|
124
|
+
<img src="./tests/assets/2.png">
|
|
125
|
+
|
|
126
|
+
<img src="./tests/assets/3.png">
|
|
127
|
+
|
|
128
|
+
<img src="./tests/assets/4.png">
|
|
129
|
+
|
|
130
|
+
<img src="./tests/assets/5.png">
|
|
131
|
+
|
|
132
|
+
<img src="./tests/assets/6.png">
|
|
133
|
+
|
|
134
|
+
<img src="./tests/assets/10.png">
|
|
135
|
+
|
|
136
|
+
<img src="./tests/assets/7.png">
|
|
137
|
+
|
|
138
|
+
## 5.License
|
|
20
139
|
[MIT licensed](./LICENSE).
|