qt qml 刮刮卡效果
来源:互联网 发布:淘宝电商差评怎么回复 编辑:程序博客网 时间:2024/05/01 04:40
用canvas+mouseArea实现的刮刮卡效果。
表层是一层色彩,用手指划开,可看到下面的文字
Lisence: MIT, 请保留本文档说明
Author: surfsky.cnblogs.com 2015-02
【先看效果】
【下载】
http://download.csdn.net/detail/surfsky/8445011
【核心代码】
1 Canvas { 2 id: canvas 3 anchors.fill: parent 4 5 // 6 property bool isFirstPaint : true; 7 property point lastPt; 8 9 //10 onPaint: {11 var ctx = getContext('2d');12 if (isFirstPaint){13 // 首次绘制刮刮层图案14 ctx.fillStyle = root.maskColor;15 ctx.fillRect(0, 0, width, height);16 isFirstPaint = false;17 }18 else{19 // 去除鼠标位置的图案20 clearRound(ctx, lastPt, 20);21 lastPt = Qt.point(area.mouseX, area.mouseY);22 }23 }24 25 // 清除圆形区域26 function clearRound(ctx, p, r)27 {28 ctx.save();29 ctx.globalCompositeOperation = 'destination-out';30 ctx.beginPath();31 ctx.arc(p.x, p.y, r, 0, 2*Math.PI, false);32 ctx.fill();33 ctx.restore();34 }35 36 // 记录下最后的鼠标点,并请求canvas重绘37 MouseArea {38 id: area39 anchors.fill: parent40 onPressed: {canvas.lastPt = Qt.point(mouseX, mouseY);}41 onPositionChanged: {canvas.requestPaint();}42 }43 }
转载请注明出处:http://surfsky.cnblogs.com
0 0
- qt qml 刮刮卡效果
- qt qml fuzzyPanel 毛玻璃效果
- Qt QML
- Qt用qml实现简单的粒子效果
- Qt用qml实现简单的粒子效果
- Qt-QML-Button-ButtonStyle-实现鼠标滑过点击效果
- QML PathView 效果
- QML滚动、翻转效果
- QML遮罩效果
- QML翻转效果Demo
- QML实现钟表效果
- Qml翻转效果
- QML for QT 1
- wince Qt QML
- qt 中调用QML
- QT程序员使用QML
- Qt(QML)本地化
- Qt QML简介
- fatal error: libmemcached/memcached.h: No such file or directory
- 关于node.js的学习16
- C#导出EXCEL文件,过长的数值被显示为科学技术法
- TextUtils类中的isEmpty,isDigitsOnly
- 产生数
- qt qml 刮刮卡效果
- H.264编解码技术[原始积累二]
- C++引用
- JAVA中堆和栈的区别
- HashMap解决hash冲突的方法
- NOIP2016提高组复赛赛后总结
- Android无源码调试Native代码(使用GDB)
- rabbitmq集群节点操作
- 深度学习-利用卷积网络识别动物