//页面容器
<div class="canvas_loop" v-show="isCanvas">
<canvas id="can" width="490" height="490" style=" margin:0 auto;"></canvas>
</div>
//调用
Rds.init() //雷达主体
/***绘制实体**/
var ocanvas = null;
var obj1=null;
var bFirst=false;
var r2=null;
var r1=0;
var R=null
export const init=function(){
ocanvas = document.getElementById("can");
if(ocanvas){
obj1 = CreateCanvasObject(draw);
R = Math.sqrt(Math.pow(obj1.Node.width/2,2)+Math.pow(obj1.Node.height/2,2));
r1=0,r2=R/2,bFirst=true;
obj1.start();
}
}
export const clear=function () {
obj1.clear()
}
export const CreateCanvasObject=function(func){
//返回的对象 包含节点Node 绘图环境GC 等属性 和 clear 等方法
var obj = new Object();
var ocolor='';
if(ocanvas.currentStyle)
ocolor = ocanvas.currentStyle['backgroundColor'];
else
ocolor ="#333";
//这里要做判断 是否获取到canvas标签 否则返回 null
//获取画布绘图环境
var ocanvasGC = ocanvas.getContext('2d');
obj =
{
Node:ocanvas,
GC:ocanvasGC,
timer:'',
bContinue:
前端js+canvas实现雷达扫描效果
最新推荐文章于 2024-06-28 18:00:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)