VueTopo纯代码绘制canvas可配置缩放拓扑图,含动画。
展示效果网址:http://jstopo.top
可配置冷通道2d环境模拟3D效果—绘制机房设备
preloadImage(path){//加载图片封装
return new Promise((resolve, reject)=>{
let image = new Image();
image.onload = resolve;
image.onerror = reject;
image.src = require('@/assets/coldRoad/'+path+'.png');
});
},
init(){
const dom = this.$refs["cold"];
let w = dom.width = dom.clientWidth,
h = dom.height = dom.clientHeight;
const ctx = dom.getContext("2d"),lineWidth = 2;
this.ctx = ctx,
this.w = w,
this.h = h,
this.lineWidth = lineWidth;
this.rePaintOnce(ctx, w, h, lineWidth);
this.rePaint(ctx, w, h, lineWidth);
},