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

边栏推荐
- Database overview
- A summary of the experiment of continue and break in C language
- Construction scheme of distributed websocket
- SRC platform summary
- Basic knowledge of web pages (URL related)
- Page electronic clock (use js to dynamically obtain time display)
- Get to know the drawing component of flutter - custompaint
- JS function to realize simple calculator
- ThinkPHP 5 log management
- What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect
猜你喜欢

Read the general components of antd source code

Kotlin compose perfect todo project surface rendering background and shadow

XSS (cross site script attack) summary (II)
![[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear](/img/12/d41f8d5abcb61d2632a8b117bf1604.jpg)
[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear

MySQL prevents Chinese garbled code and solves the problem of Chinese garbled code

What is Ethernet and how to connect the computer

Matlab notes

leetcode1221. Split balance string

Detailed summary of flex layout

【FLink】access closed classloader classloader. check-leaked-classloader
随机推荐
JDBC (IV)
基于SSH实现的学生成绩管理系统
Working principle of asemi three-phase rectifier bridge
Why is the TCP handshake just 3 times?
【图像融合】基于matlab方向离散余弦变换和主成分分析图像融合【含Matlab源码 1907期】
Database low-end SQL query statement fragment
小白一键重装官网下载使用方法
Web3 DAPP user experience best practices
OLAP analysis engine kylin4.0
Laravel Aurora push
ORA-00800: soft external error
A summary of the experiment of continue and break in C language
Huawei Hongmeng development lesson 4
Using JS to realize the sidebar of life information network
MySQL concept and operation (III)
PHP calls map API
ThinkPHP 5 log management
Apache+php uploading large files
WPF uses Maui's self drawing logic
Laravel Vonage SMS sending