当前位置:网站首页>Wechat applet canvas draws a simple asymptotic color of the dashboard
Wechat applet canvas draws a simple asymptotic color of the dashboard
2022-04-23 03:32:00 【I can fix software】
wxml <canvas type="2d" id="myCanvas" class="secondView" > </canvas>
js part
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;
// Draw background chassis
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 Microsoft YaHei ';
ctx.fillText(' Issued ', cicleCenterX, cicleCenterY*3/4);
ctx.font='normal blod 22px Microsoft YaHei ';
ctx.fillText('88,888 element ', cicleCenterX, cicleCenterY);
ctx.fillStyle='#e35702';
ctx.font='normal normal 16px Microsoft YaHei ';
ctx.fillText(' Total bonus :1,000,000 element ', cicleCenterX, cicleCenterY*5/4);
ctx.fillStyle='#e35702';
ctx.font='normal normal 14px Microsoft YaHei ';
ctx.fillText(' Handle the business , You can get 10 element ', cicleCenterX, canvasHigth-5);
ctx.font='normal normal 16px Microsoft YaHei ';
ctx.fillText(' Rush progress ', 50,30);
// Draw the fill color section
ctx.beginPath();
ctx.rect(5, 10, 5, 25);
ctx.fillStyle='#ffa600';
ctx.fill();
// Draw the fill color section
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();
});
}
effect :
版权声明
本文为[I can fix software]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220607290981.html
边栏推荐
- The art of concurrent programming (6): explain the principle of reentrantlock in detail
- The art of concurrent programming (3): an in-depth understanding of the principle of synchronized
- 7-2 Tushare
- Generate QR code through zxing
- Using swagger in. Net5
- POI create and export Excel based on data
- JS - accuracy issues
- TCP three handshakes and four waves
- Common exceptions
- Development record of primary sensitive word detection
猜你喜欢
打卡:4.22 C语言篇 -(1)初识C语言 - (11)指针
Design and implementation of redis (6): how redis achieves high availability
超好用的【通用Excel导入功能】
C set
On the principle of concurrent programming and the art of notify / Park
Test questions and some space wars
Build websocket server in. Net5 webapi
TCP three handshakes and four waves
2022 团体程序设计天梯赛 模拟赛 1-8 均是素数 (20 分)
Unity knowledge points (ugui)
随机推荐
Redis(17) -- Redis缓存相关问题解决
QT learning summary
JS inheritance
Problem C: Hanoi Tower III
Download and configuration of idea
Notes sur l'apprentissage profond (Ⅱ) - - Principe et mise en oeuvre de la fonction d'activation
Oracle query foreign keys contain comma separated data
2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
"Visual programming" test paper
Unity Basics
Alphafpld upgrade alphafold multimer
Definition format of array
JS - accuracy issues
Design and implementation of redis (6): how redis achieves high availability
场景题:A系统如何使用B系统的页面
Several common methods of multithreading
The fourth operation
Cefsharp stores cookies and reads cookies
C-11 problem I: find balloon
第四次作业