A canvas engine for interactive graphics.
npm install ice-render
javascript
let ice = new ICE.ICE().init('canvas-1');
let rect = new ICE.ICERect({
left: 1024 * Math.random(),
top: 768 * Math.random(),
width:50,
height:50,
style:{
strokeStyle:'#ff3300',
fillStyle:'#00ff00',
}
});
ice.addChild(rect);
`
在此项目的 /test 目录下,提供了大量直接在浏览器中使用的例子,请参考: https://github.com/ice-render/ice-render
$3
在你的项目中安装依赖:
`shell
npm i ice-render --save
`
基于 ice-render 提供的类和接口二次开发,示例:
`javascript
import { ICEVisioLink } from 'ice-render';
export default class Relation extends ICEVisioLink {
constructor(props) {
super({
title: 'Relation',
relationType: 'one-to-one',
referencedColumnName: 'id',
...props,
});
}
/**
* 实体类的 JSON 格式描述,与 type-orm 规定的格式对应
*/
public toEntityObject(): any {
let { title, relationType, referencedColumnName } = this.state;
let fromComponent, toComponent, fromId, fromName, toId, toName;
if (this.state.links && this.state.links.start && this.state.links.start.id) {
fromId = this.state.links.start.id;
fromComponent = this.ice.findComponent(fromId);
fromName = fromComponent.state.entityName;
}
if (this.state.links && this.state.links.end && this.state.links.end.id) {
toId = this.state.links.end.id;
toComponent = this.ice.findComponent(toId);
toName = toComponent.state.entityName;
}
let result = {
title,
fromId,
fromName,
toId,
toName,
relationType,
referencedColumnName,
};
return result;
}
}
``