当前位置:网站首页>The first lesson is canvas, showing a small case
The first lesson is canvas, showing a small case
2022-04-23 13:05:00 【It's never too late to be alone】
There's not much work today , I have time to learn about canvas, By the way, I drew a “ Ding ” old man , It is hereby displayed , Just waiting for the public to have fun !
It's not good ????
Forget it , Hot eyes are hot eyes , Look at the code .
<canvas id="canvas" width="500" height="500"></canvas>
var canvas = document.getElementById("canvas");
var context = canvas.getContext('2d');
// First draw a head
context.beginPath();
context.arc(250,250,50,0,Math.PI*2);
context.stroke();
// Draw two more ears
context.beginPath();
context.arc(200,200,20,0,Math.PI*2);
context.fill();
context.beginPath();
context.arc(300,200,20,0,Math.PI*2);
context.fill();
// Draw two more eyes
context.beginPath();
context.arc(230,240,10,0,Math.PI*2);
context.stroke();
context.beginPath();
context.arc(270,240,10,0,Math.PI*2);
context.stroke();
// Mend two eyes
context.beginPath();
context.arc(230,240,2,0,Math.PI*2);
context.fill();
context.beginPath();
context.arc(270,240,2,0,Math.PI*2);
context.fill();
// Draw another triangular nose
context.beginPath();
context.moveTo(250,250);// Point a point in the canvas , Don't create lines
context.lineTo(240,260);// Add a new point , Then create a line from this point to the last specified point in the canvas ( This method does not create lines )
context.lineTo(260,260);// Add a new point , Then create a line from this point to the last specified point in the canvas ( This method does not create lines )
context.closePath();// The end point returns to the starting point
context.stroke();
// Draw another mouth
context.beginPath();
context.arc(250,270,15,0,Math.PI,false);
context.stroke();
Look at this ,canvas It's still fun
版权声明
本文为[It's never too late to be alone]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231303466040.html
边栏推荐
- Go language: passing slices between functions
- Async void provoque l'écrasement du programme
- Byte jump 2020 autumn recruitment programming question: quickly find your own ranking according to the job number
- 安装nngraph
- Byte warehouse intern interview SQL questions
- Custom nail robot alarm
- Introduction to servlet listener & filter
- three.js文字模糊问题
- Pytorch: a pit about the implementation of gradreverselayer
- 8 websites that should be known for product development to enhance work experience
猜你喜欢
Melt reshape decast long data short data length conversion data cleaning row column conversion
R语言中dcast 和 melt的使用 简单易懂
SSM framework series - data source configuration day2-1
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误
Summary of JVM knowledge points - continuously updated
拥抱机器视觉新蓝海,冀为好望开启数字经济发展新“冀”遇
Unable to create servlet under SRC subfile of idea
Importerror after tensorflow installation: DLL load failed: the specified module cannot be found, and the domestic installation is slow
Embrace the new blue ocean of machine vision and hope to open a new "Ji" encounter for the development of digital economy
随机推荐
CGC: contractual graph clustering for community detection and tracking
31. 下一个排列
Important knowledge of network layer (interview, reexamination, term end)
pyqt5 将opencv图片存入内置SQLlite数据库,并查询
100 GIS practical application cases (34) - splicing 2020globeland30
mysql支持ip访问
Subscribe to Alibaba demo send business messages
Customize the shortcut options in El date picker, and dynamically set the disabled date
Introducing vant components on demand
安装nngraph
Three channel ultrasonic ranging system based on 51 single chip microcomputer (timer ranging)
SSM framework series - JUnit unit test optimization day2-3
Record some NPM related problems (messy records)
AUTOSAR from introduction to mastery 100 lectures (50) - AUTOSAR memory management series - ECU abstraction layer and MCAL layer
Start mqbroker CMD failure resolution
Custom nail robot alarm
SSM framework series - data source configuration day2-1
MySQL -- 16. Data structure of index
Record a website for querying compatibility, string Replaceall() compatibility error
进程虚拟地址空间区域划分