当前位置: 首页 > news >正文

杭州蒙特网站建设网页设计制作网站图片

杭州蒙特网站建设,网页设计制作网站图片,福州短视频seo费用,上海市场调研公司1. 说明 本篇文章在14. 利用Canvas组件制作时钟的基础上进行一些更改,想查看全面的代码可以点击链接查看即可。 效果展示: 2. 整体代码 import QtQuick 2.15 import QtQuick.Controls 2.15Item{id:rootimplicitWidth: 400implicitHeight: implicitWi…

1. 说明

本篇文章在14. 利用Canvas组件制作时钟的基础上进行一些更改,想查看全面的代码可以点击链接查看即可。
效果展示:
在这里插入图片描述

2. 整体代码

import QtQuick 2.15
import QtQuick.Controls 2.15Item{id:rootimplicitWidth: 400implicitHeight: implicitWidth// 尺寸属性property real outerCircleRadius:root.width / 2.05property real innerCircleRadius:root.width / 2.05// 颜色属性property color bgColor:Qt.rgba(0,0,0,0)property color outerColor:"black"property color innerColor:"black"property color innerRootColor:"lightSlateGray"property color innerLineColorL:Qt.rgba(1,1,1,1)property color innerLineColorS:Qt.rgba(1,1,1,0.8)property color textColor:"white"property color secondLineColor:"red"// 指针property var secondsproperty alias secondsAngle:secondLine.angle// 绘制背景Canvas{id:bgCirclewidth: root.widthheight: root.heightanchors.centerIn: parentonPaint: {// 绘制背景var ctx = getContext("2d")  ctx.save()ctx.lineWidth = root.width/50   ctx.fillStyle = bgColorctx.beginPath()ctx.arc(root.width/2,root.height/2,outerCircleRadius,Math.PI * (5/6),Math.PI * (1/6))ctx.fill()ctx.restore()}}// 绘制圆环轮廓Canvas{id:outerCirclewidth: root.widthheight: root.heightanchors.centerIn: parentonPaint: {var ctx = getContext("2d")  //创建画师//为画师创建画笔并设置画笔属性ctx.lineWidth = root.width/50   //设置画笔粗细ctx.strokeStyle = outerColor    //设置画笔颜色ctx.beginPath()     //每次绘制调用此函数,重新设置一个路径// 按照钟表刻度进行划分,一圈是Math.PI * 2,分成12个刻度,每个刻度占用 1/6// canvas绘制圆弧,是按照顺时针绘制,起点默认在三点钟方向ctx.arc(root.width/2,root.height/2,outerCircleRadius,Math.PI * (5/6),Math.PI * (1/6))ctx.stroke()    //根据strokeStyle对边框进行描绘}}// 绘制秒针线Canvas{id:secondLinewidth: root.widthheight: root.heightanchors.centerIn: parentproperty real angle:Math.PI * (8/6)onPaint: {var ctx = getContext("2d")ctx.clearRect(0,0,width,height)ctx.save()ctx.beginPath()ctx.lineWidth = root.width/100ctx.strokeStyle=secondLineColor// 平移坐标点(注意:坐标系原点先平移,再旋转)ctx.translate(root.width/2,root.height/2)// 旋转坐标系ctx.rotate(angle)// 坐标原点变化之后再进行实际的绘图ctx.moveTo(0,-10);ctx.lineTo(0,outerCircleRadius / 1.5);ctx.stroke()ctx.restore()}}// 绘制圆环内衬Canvas{id:innerCirclewidth: root.widthheight: root.heightanchors.centerIn: parentproperty real endAngle:Math.PI * (12/6)onPaint: {var ctx = getContext("2d")  ctx.save()ctx.lineWidth = root.width/50   ctx.strokeStyle = innerColor     ctx.beginPath()     ctx.arc(root.width/2,root.height/2,innerCircleRadius,Math.PI * (5/6),Math.PI * (1/6))ctx.stroke()    ctx.restore()// 绘制指针根部圆圈ctx.save()ctx.lineWidth = root.width/50   ctx.fillStyle = innerRootColorctx.beginPath()ctx.arc(root.width/2,root.height/2,innerCircleRadius/8,0,endAngle)ctx.fill()ctx.restore()}}// 绘制刻度线Canvas{id:innerLinewidth: root.widthheight: root.heightanchors.centerIn: parentproperty real lineNums:60onPaint: {var ctx = getContext("2d")  for (var i = 0; i <= lineNums; ++i){if(i > 5 && i < 25){continue}ctx.beginPath();var angle = 2 * Math.PI / 60 * i;var dx = Math.cos(angle)*(outerCircleRadius-15);var dy = Math.sin(angle)*(outerCircleRadius-15);var dx2 = Math.cos(angle)*(outerCircleRadius-7);var dy2 = Math.sin(angle)*(outerCircleRadius-7);if (i % 5 === 0 && i != 25 && i != 30){ctx.lineWidth = root.width/100ctx.strokeStyle = innerLineColorL}else if(i >= 25 && i <= 30){ctx.strokeStyle = "red"}else{ctx.lineWidth = root.width/200ctx.strokeStyle = innerLineColorS}ctx.moveTo(root.width/2+dx,root.height/2+dy);ctx.lineTo(root.width/2+dx2,root.height/2+dy2);ctx.stroke();}}}// 绘制数字Canvas{id:drawTextwidth: root.widthheight: root.heightanchors.centerIn: parentproperty var numbers : [1,2,3,4,5,6,7,8,9,10,11,12]onPaint: {var ctx = getContext("2d")ctx.font = "18px Arial";ctx.textAlign = "center";ctx.textBaseline = "middle";for(var i = 0; i < 12; ++i){ctx.fillStyle = textColorvar angle = 2 * Math.PI / 12 * numbers[i] - 3.14 / 2;var dx = Math.cos(angle)*(outerCircleRadius-35);var dy = Math.sin(angle)*(outerCircleRadius-35);switch(i){case 3:ctx.fillText(1,root.width/2 + dx,root.height / 2 + dy);ctx.fill()breakcase 7:ctx.fillText(0,root.width/2 + dx,root.height / 2 + dy);ctx.fill()breakcase 11:ctx.fillText("1/2",root.width/2 + dx,root.height / 2 + dy);ctx.fill()breakdefault:break}}}}Image{id:iconImganchors.horizontalCenter: parent.horizontalCenteranchors.top: parent.topanchors.topMargin: 5scale: 0.25source: "qrc:/油箱.png"}
}
http://www.mmbaike.com/news/56625.html

相关文章:

  • 为什么有的网站打不开网站优化比较好的公司
  • 天津免费网站建站模板十大免费cms建站系统介绍
  • java和php做网站网站搜什么关键词好
  • 杭州移动网站建设刚出来的新产品怎么推
  • 网站动效怎么做的常用的五种网络营销工具
  • 微信做单子的网站源码西安企业网站seo
  • 网站成立查询百度导航怎么下载
  • 东铁匠营网站建设正规网站优化哪个公司好
  • 湘潭网站建设 皆来磐石网络整站seo排名费用价格
  • 做外贸要做什么网站营销公司网站
  • 有哪些做相册视频剪辑的网站百度官网入口链接
  • 建一个网站流程seo关键词首页排名代发
  • 区块链网站用vue.js做怎么样百度上怎么发布作品
  • 买完域名怎么创建网站引擎网站推广法
  • 西安短视频制作公司深圳搜索引擎优化收费
  • 怎么做自己的cpa网站优化公司组织架构
  • 昆明网站制作seo快排优化
  • 企业推广的主要目的是太原seo排名优化公司
  • 优化方案历史某个网站seo分析实例
  • wordpress特定页面设为主页seo的中文意思
  • 昆山建设企业网站seo优化工程师
  • 谷歌可以做网站吗佛山做网站建设
  • 邢台营销型网站建设费用长沙做网站推广公司咨询
  • 手機如何做网站今日头条重大消息
  • 邢台市防疫办电话是多少网站seo价格
  • 菏泽北京网站建设百度推广开户费用
  • 人人秀h5制作软件下载惠州市seo广告优化营销工具
  • 做软件营销网站怎么样网络黄页推广软件哪个好
  • 网站建建设公司和网络自建成都有实力的seo团队
  • 德国域名申请网站网络营销课程培训课程