当前位置:网站首页>H5 canvas drawing circle drawing fillet [detailed explanation]
H5 canvas drawing circle drawing fillet [detailed explanation]
2022-06-25 05:05:00 【I am Feng Feng Yi】
canvas yes H5 A big point of
Let's learn how to use canvas A circle
A circle
arc(x,y,r, Initial radian , End arc , Clockwise and counterclockwise )
- x,y Is the coordinates of the center of the circle
- r It's the radius of the circle
- Radian unit is Math.PI
- Clockwise and counterclockwise 0( Clockwise ) 1( Anti-clockwise )
const cas = document.getElementsByTagName('canvas')[0];
const ctx = cas.getContext("2d");
ctx.arc(250,250,100,0,Math.PI / 2,1);
ctx.stroke();

The starting point and the ending point are the same , But it is different to draw it clockwise and anticlockwise
const cas = document.getElementsByTagName('canvas')[0];
const ctx = cas.getContext("2d");
ctx.arc(250,250,100,0,Math.PI / 2,0);
ctx.stroke();
The circle above , Let's change direction , Clockwise 
Draw round corners
Let's first understand a canvas The drawing method of round corner in .
We need to know 3 A little bit 
arcTo(bx,by,cx,cy, Fillet size )
Let me explain the size of the fillet : Is the radius of the circle of the tangent angle .
If you understand the picture above , So let me draw a rounded rectangle , See if you really understand
var can = document.getElementsByTagName('canvas')[0];
var ctx = can.getContext('2d');
ctx.moveTo(100,110); // Why not 100 100
// You can change it to 100, See what happens
ctx.arcTo(100,200,105,200,10);
ctx.arcTo(200,200,200,199,10);
ctx.arcTo(200,100,199,100,10);
ctx.arcTo(100,100,100,105,10);
ctx.stroke();

边栏推荐
- 本轮压力测试下,DeFi协议们表现如何?
- Redis (17)
- Introduction to the hardest core PWN in the whole network_ Graphic analysis
- MySQL concept and operation (III)
- SOC验证环境的启动方式
- Wechat applet new version prompt update
- 基于SSH实现的学生成绩管理系统
- Svg code snippet of loading animation
- Separation of storage and computing in Dahua cloud native database
- Use js to simply implement the apply, call and bind methods
猜你喜欢

小白一键重装官网下载使用方法

CTFHub-rce

Deeply understand the characteristics of standard flow and off standard elements

EL & JSTL (XIII)

File upload vulnerability (III)

Virtual honeypot Honeyd installation and deployment

buuctf(re)

Why does the SQL statement hit the index faster than it does not?

February 20ctf record

Summary of SQL injection (I)
随机推荐
Records of ros2/dds/qos/ topics
Difference between asemi high power FET and triode
How to make colleagues under the same LAN connect to their own MySQL database
以太网是什么要怎么连接电脑
What is Ethernet and how to connect the computer
Get to know the drawing component of flutter - custompaint
Implementation of websocket long connection by workman under laravel
Response (XI)
Ranorex Studio 10.1 Crack
Web3 DAPP user experience best practices
In Net 6 using dotnet format formatting code
Database low-end SQL query statement fragment
Mobile number regular expression input box loses focus verification
Integrate CDN to create the ultimate service experience for customers!
渗透测试-目录遍历漏洞
Calculate student grade (virtual function and polymorphism)
Kotlin compose perfect todo project surface rendering background and shadow
JS function to realize simple calculator
JS, BOM, DOM (VI)
[image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]