当前位置:网站首页>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 principle and solution of not allowing pasting in an English Network
- Codeforces round 784 (Div. 4) (AK CF (XD) for the first time)
- . net 5 Web custom middleware implementation returns the default picture
- 2021-08-31
- 月薪10k-20k都无法回答的事务问题,你会吗?
- File upload vulnerability summary and upload labs shooting range documentary
- 打卡:4.22 C语言篇 -(1)初识C语言 - (11)指针
- Mechanical design knowledge point planning
- Batch download of files ---- compressed and then downloaded
- Using jsonserialize to realize data type conversion gracefully
猜你喜欢
![Super easy to use [general excel import function]](/img/9b/ef18d1b92848976b5a141af5f239b5.jpg)
Super easy to use [general excel import function]

深度學習筆記(二)——激活函數原理與實現

Unity knowledge points (common core classes)

Problem a: face recognition

Redis (17) -- redis cache related problem solving

Unity Basics

Translation of l1-7 matrix columns in 2022 group programming ladder Simulation Competition (20 points)

MySQL之explain关键字详解

Database SQL -- simulate inserting a large amount of data, importing / exporting database scripts, timestamp conversion and database basics

Codeforces Round #784 (Div. 4)題解 (第一次AK cf (XD
随机推荐
2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
Idempotency practice operation, explaining idempotency based on business
JS implementation of new
2022 group programming ladder game simulation L2-4 Zhezhi game (25 points)
Design and implementation of redis (3): persistence strategy RDB, AOF
【微服务】(十)—— 统一网关Gateway
Detailed explanation of socket programming send() and recv() functions
淺學一下I/O流和File類文件操作
C-11 problem I: find balloon
Punch in: 4.22 C language chapter - (1) first knowledge of C language - (11) pointer
Idea view history [file history and project history]
Query stored procedures in PostgreSQL
Un aperçu des flux d'E / s et des opérations de fichiers de classe de fichiers
Applet - WXS
Unity knowledge points (ugui 2)
Initial experience of talent plan learning camp: communication + adhering to the only way to learn open source collaborative courses
C interface
ThreadLocal test multithreaded variable instance
Supersocket is Use in net5 - startup
Three types of cyclic structure