当前位置:网站首页>微信小程序 canvas 画简单的仪表盘 渐近色
微信小程序 canvas 画简单的仪表盘 渐近色
2022-04-22 06:09:00 【我会修软件】
wxml <canvas type="2d" id="myCanvas" class="secondView" > </canvas>
js部分
drawCanvas: function (canvasWidth,canvasHigth){
wx.createSelectorQuery().select('#myCanvas').fields({ node: true, size: true }).exec(res => {
const canvas = res[0].node;
const ctx = canvas.getContext('2d');
canvas.width=canvasWidth;
canvas.height=canvasHigth;
let cicleCenterX=canvasWidth/2;
let cicleCenterY=canvasHigth*11/20;
//绘制背景底盘
ctx.beginPath();
ctx.arc(cicleCenterX, cicleCenterY, 90, 0.8* Math.PI, 2.2* Math.PI)
ctx.strokeStyle = '#ffa600';
ctx.lineWidth = 4;
ctx.setLineDash([0]);
ctx.stroke();
ctx.fillStyle='#3366ff';
ctx.textAlign='center';
ctx.font='normal normal 16px 微软雅黑';
ctx.fillText('已发放', cicleCenterX, cicleCenterY*3/4);
ctx.font='normal blod 22px 微软雅黑';
ctx.fillText('88,888元', cicleCenterX, cicleCenterY);
ctx.fillStyle='#e35702';
ctx.font='normal normal 16px 微软雅黑';
ctx.fillText('总奖金:1,000,000元', cicleCenterX, cicleCenterY*5/4);
ctx.fillStyle='#e35702';
ctx.font='normal normal 14px 微软雅黑';
ctx.fillText('办理业务,每笔均可获得10元', cicleCenterX, canvasHigth-5);
ctx.font='normal normal 16px 微软雅黑';
ctx.fillText('抢盘进度', 50,30);
//绘制填充颜色部分
ctx.beginPath();
ctx.rect(5, 10, 5, 25);
ctx.fillStyle='#ffa600';
ctx.fill();
//绘制填充颜色部分
ctx.beginPath();
const grd = ctx.createLinearGradient(0, 0, 200, 0)
grd.addColorStop(0, '#ffa600')
grd.addColorStop(1, 'red')
ctx.arc(cicleCenterX, cicleCenterY, 90, 0.8* Math.PI, 1.6* Math.PI);
ctx.strokeStyle = grd;
ctx.lineWidth = 5;
ctx.setLineDash([0]);
ctx.stroke();
});
}
效果:

版权声明
本文为[我会修软件]所创,转载请带上原文链接,感谢
https://blog.csdn.net/IT837684734/article/details/105082491
边栏推荐
- Changes in the number of different types of calls in different months in 911 data
- Typec转HDMI 4K30HZ扩展芯片方案CS5261和CS5266设计参数及电路对比
- Alternative ag9311 design circuit | cs5266 application circuit diagram | design and development of three in one scheme of typec docking station
- RT thread transplantation BSP driven UART
- [蓝桥杯复习] 鸣人的影分身
- STM32WB55 蓝牙协议栈运行流程解析
- Application of usbcan card in CAN bus in EOL test system of power battery pack
- STM32学习记录0001——学习准备
- CS5268开发TypeC转HDMI+VGA+PD+U3+3.5音频五合一扩展音视频转换方案参考设计
- RT-Thread 软件包制作及发布流程
猜你喜欢

Why not recommend tin spraying process for high-speed PCB with crimping devices

Td041s485h is fully compatible with iso3080, iso3086, iso3082 and iso3088

集成电路模拟版图入门-版图基础学习笔记(五)

Alternative ag9311 design circuit | cs5266 application circuit diagram | design and development of three in one scheme of typec docking station

替代RTD2171U|CS5266设计电路|TYPEC转HDMI方案|CS5266AN

Application of can optical transceiver in fire networking

阿里云部署RSSHub踩坑笔记

SSS1700 QFN36单芯片设计一款USB Typec耳机|支持线控和欧美规自动切换USB耳机方案

PL2586设计电路|PL2586替代FE1.1S电路图|USB2.0HUB工业级集线器方案设计

STM32 learning record 0003 -- Interpretation of STM32 chip
随机推荐
51单片机:D/A数模转换实验
6. What is ROS
LwIP 1.4.1 Chinese annotation source code
STM32 learning record 0001 - learning preparation
SSS1700
STM32学习记录0002-STM32初探
Latex符号与公式集合
LwIP 1.4.1中文注释源码
It's nothing to be able to dismantle the host. Mr. expressway can also test it
Is there any difference in the worst impedance processing you have encountered?
DDR4 signal refers to the power layer. Will the impedance be affected?
[review of Blue Bridge Cup] Naruto's shadow split
C skill tree evaluation - 0415 experience diary
替代FE1.1S,MA8601,性价比高,中文方案,奇岩一级代理,HUB方案
LCFNET系列CAN转光纤以太网设备实现CAN网络之间超远距离光纤连通
Handwritten numeral recognition in deep learning environment
模拟ic设计和数字ic设计的区别,含薪资表
Experiment 4 cycle program design
miniPCIe接口CAN卡为工控机扩展CAN通道
The buried mine design of PCB mark is short circuited, but no trace can be found