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();
}
}
}
}

Qt-QML-Canvas-雷达扫描仪表简单的更多相关文章
- 【canvas系列】canvas实现"雷达扫描"效果
今天来讲解"雷达扫描"效果demo,来源于QQ群里边有群友说想要个雷达效果,就尝试写了一下. 效果图: demo链接: https://win7killer.github.io/c ...
- canvas实现"雷达扫描"效果
今天来讲解“雷达扫描”效果demo,来源于QQ群里边有群友说想要个雷达效果,就尝试写了一下. 效果图: demo链接: https://win7killer.github.io/can_demo/de ...
- qt qml qchart 图表组件
qt qml qchart 图表组件 * Author: Julien Wintz * Created: Thu Feb 13 23:41:59 2014 (+0100) 这玩意是从chart.js迁 ...
- Qt qml listview 列表视图控件(下拉刷新、上拉分页、滚动轴)
Qt qml listview下拉刷新和上拉分页主要根据contentY来判断.但要加上顶部下拉指示器.滚动条,并封装成可简单调用的组件,着实花了我不少精力:) [先看效果] [功能] 下拉刷新 ...
- Qt QML referenceexamples attached Demo hacking
/********************************************************************************************* * Qt ...
- 【Flutter 实战】自定义动画-涟漪和雷达扫描
老孟导读:此篇文章是 Flutter 动画系列文章第五篇,本文介绍2个自定义动画:涟漪和雷达扫描效果. 涟漪 实现涟漪动画效果如下: 此动画通过 CustomPainter 绘制配合 Animatio ...
- Qt qml 单例模式
Qt qml 单例模式,没什么好说的,看代码吧.单例模式很适合做全局的配置文件. [示例下载] http://download.csdn.net/detail/surfsky/8539313 [以下是 ...
- qt qml中PropertyAnimation的几种使用方法
qml文章 qt qml中PropertyAnimation的几种使用方法 动画应用场景有以下几种: 首先如果一个Rectangle.动画是要改变它的x和y值 1,Rectangle一旦被创建,就要移 ...
- html 类似雷达扫描效果 及 闪屏效果
//雷达扫描效果 1 <em id="Radar" class="RadarFast"></em> css: .RadarFast{ p ...
随机推荐
- keras写模型时遇到的典型问题,也是最基础的类与对象问题
自己定义了一个卷积类,现在需要把卷积加入model中,我的操作是这样的: model.add(Convolution1dLayer) 这样就会报错: 正确的写法是: model.add(Convolu ...
- JDK(三)JDK1.8源码分析【排序】mergeSort
归并排序是JDK对象数组的排序算法之一,接下来开始分析JDK的归并排序算法. /** * 将指定范围的对象数组按自然顺序升序排序 * * Src is the source array that st ...
- 【luogu P1373 小a和uim之大逃离】 题解
题目链接:https://www.luogu.org/problemnew/show/P1373 想不出来状态 看了一眼题解状态明白了 dp[i][j][h][1/0] 表示在i,j点差值为h是小A还 ...
- Android 异步开发之 AsyncQueryHandler 批量添加联系人
AsyncQueryHandler: 官方解释是一个异步帮助类(A helper class to help make handling asynchronous ContentResolver qu ...
- HDU Virtual Friends(超级经典的带权并查集)
Virtual Friends Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 【JavaScript-基础-文件上传】
Upload 最原始方式 form表单提交 // html <form method="get" action="/test/upload"> &l ...
- iOS 地图相关
参考博文:https://blog.csdn.net/zhengang007/article/details/52858198?utm_source=blogxgwz7 1.坐标系 目前常见的坐标系有 ...
- dfs板子题-Hdu1283Vegetables
题目描述毕业后,Vegetable在一家建筑公司找到了工作.他所在的城市将要进行整修,要求把所有空地修成公园. 市区是一个N*M的矩形,Vegetable拿到了该市的地图,现在判断共要修几处公园? 注 ...
- 19-3-8Python中编码的进阶、文件操作初识、深浅copy
编码的进阶 ASCII:英文字母,数字,特殊符号,——> 二进制的对应关系 Str: 1个字符——> 1个字节 Unicode:万国码:世界上所有的文字与二进制的对应关系 1个字符——& ...
- MySQL学习【第八篇索引优化】
一.建立索引的原则(规范) 1.选择唯一性索引 只要可以创建唯一性索引的,一律创建唯一索引(因为速度快呀) 判断是否能创建唯一索引,用count(列名),count(distinct(列名))一样就能 ...