当前位置:网站首页>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();

边栏推荐
- Teach you to write non maintainable PHP code step by step
- 融合CDN,为客户打造极致服务体验!
- How to install the blue lake plug-in to support Photoshop CC 2017
- Kotlin compose listens to the soft keyboard and clicks enter to submit the event
- Google Earth Engine(GEE)——全球JRC/GSW1_1/YearlyHistory数据集的批量下载(中国区域)
- Database overview
- 固態硬盤開盤數據恢複的方法
- Laravel Aurora push
- Huawei Hongmeng development lesson 4
- XML (VIII)
猜你喜欢

TeeChart Pro ActiveX 2022.1

Visual studio 2022 interface beautification tutorial

台式电脑连不上wifi怎么办

How do the defi protocols perform under this round of stress test?

Matlab notes

DOM document object model (I)

Detailed summary of position positioning

buuctf(pwn)

Chapter IX app project test (2) test tools

Read the general components of antd source code
随机推荐
epplus复制模板后打印区域变小的问题
Construction scheme of distributed websocket
为什么SQL语句命中索引比不命中索引要快?
parallel recovery slave next change & parallel recovery push change
MySQL concept and operation (III)
Why does the SQL statement hit the index faster than it does not?
固态硬盘开盘数据恢复的方法
Rce code execution & command execution (V)
Route parameters to jump to the page and transfer parameters -- > hidden parameter list
Leader: who can use redis expired monitoring to close orders and get out of here!
PHP calls map API
Use js to simply implement the apply, call and bind methods
How to open the DWG file of the computer
固態硬盤開盤數據恢複的方法
Mobile number regular expression input box loses focus verification
【Keil】ADuCM4050官方库的GPIO输出宏定义
Integrate CDN to create the ultimate service experience for customers!
The print area becomes smaller after epplus copies the template
JS, BOM, DOM (VI)
EL & JSTL (XIII)