zoukankan      html  css  js  c++  java
  • Qt-QML-Canvas-雷达扫描仪表简单

    使用QML实现的雷达仪表的实现,主要实现了余晖扫描的实现,其他的还是比较简单的,后面可能会加入目标标识,目前的功能仅仅是一个假的扫描雷达

    来看代码

    /*
    作者:张建伟
    时间:2018年4月27日
    简述:雷达仪表实现
    */
    importQtQuick2.0
    
    
    Rectangle
    {
    id:root
    width:200
    height:200
    propertyintm_Angle:0
    Timer
    {
    interval:25;running:true;repeat:true
    onTriggered:
    {
    
    
    root.m_Angle=root.m_Angle+1;
    if(root.m_Angle==360)
    {
    root.m_Angle=0;
    }
    }
    
    
    }
    color:"transparent"
    anchors.centerIn:parent
    Rectangle
    {
    anchors.fill:parent
    color:"transparent"
    Canvas
    {
    anchors.fill:parent
    onPaint:
    {
    varctx=getContext("2d");
    ctx.lineWidth=2;
    ctx.strokeStyle="#00FF00";
    ctx.fillStyle="#00FF00";
    ctx.globalAlpha=1.0;
    ctx.beginPath();
    ctx.arc(width/2,width/2,2,0,2*Math.PI);
    ctx.stroke();
    ctx.fill()
    ctx.restore();
    ctx.beginPath();
    ctx.arc(width/2,width/2,width/2-80,0,2*Math.PI);
    ctx.stroke();
    ctx.restore();
    ctx.beginPath();
    ctx.arc(width/2,width/2,width/2-60,0,2*Math.PI);
    ctx.stroke();
    ctx.restore();
    ctx.beginPath();
    ctx.arc(width/2,width/2,width/2-40,0,2*Math.PI);
    ctx.stroke();
    ctx.restore();
    ctx.beginPath();
    ctx.arc(width/2,width/2,width/2-20,0,2*Math.PI);
    ctx.stroke();
    ctx.restore();
    ctx.beginPath();
    ctx.arc(width/2,width/2,width/2-1,0,2*Math.PI);
    ctx.stroke();
    ctx.restore();
    ctx.beginPath();
    ctx.lineTo(0,width/2)
    ctx.lineTo(width,width/2)
    ctx.stroke();
    ctx.restore();
    ctx.beginPath();
    ctx.lineTo(width/2,0)
    ctx.lineTo(width/2,width)
    ctx.stroke();
    ctx.restore();
    
    
    }
    }
    Canvas{
    anchors.fill:parent
    rotation:-root.m_Angle
    onPaint:
    {
    varctx=getContext("2d");
    ctx.lineWidth=2;
    varsectorCnt=30;
    varstartDeg=90,endDeg;
    varsectorRadius=width/2
    ctx.translate(sectorRadius,sectorRadius);
    ctx.fillStyle='rgba(0,255,0,0.05)';
    
    
    for(vari=0;i<sectorCnt;i++)
    {
    endDeg=startDeg+60-60/sectorCnt*i;
    ctx.beginPath();
    ctx.moveTo(0,0);
    ctx.lineTo(0,-sectorRadius);
    ctx.arc(0,0,sectorRadius,Math.PI/180*(startDeg),Math.PI/180*endDeg);
    ctx.closePath();
    ctx.fill();
    }
    //ctx.restore();
    
    
    
    
    }
    }
    }
    }
    
    

     

  • 相关阅读:
    BZOJ5296 [CQOI2018] 破解D-H协议 【数学】【BSGS】
    Codeforces963C Frequency of String 【字符串】【AC自动机】
    Codeforces962F Simple Cycles Edges 【双连通分量】【dfs树】
    Hello World
    Codeforces963C Cutting Rectangle 【数学】
    BZOJ5203 [NEERC2017 Northern] Grand Test 【dfs树】【构造】
    20160422 --Switch…case 总结; 递归算法
    20160421字符串类型;日期时间类型数学类型
    20160420冒泡排序和查找
    20160419 while练习,复习
  • 原文地址:https://www.cnblogs.com/DreamDog/p/9159964.html
Copyright © 2011-2022 走看看