当前位置:网站首页>初鉴canvas,展示个小小的小案例
初鉴canvas,展示个小小的小案例
2022-04-23 13:04:00 【孤身不觉晚】
今天工作量不大,得空了解了一下canvas,顺便画出了一个“丁”老头,特此展示,以待大众取乐而已!
好不好看????
算了,辣眼就辣眼吧,看代码吧。
<canvas id="canvas" width="500" height="500"></canvas>
var canvas = document.getElementById("canvas");
var context = canvas.getContext('2d');
//先画一个头
context.beginPath();
context.arc(250,250,50,0,Math.PI*2);
context.stroke();
//再画两个耳朵
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();
//再画两只眼
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();
//补上两个眼珠子
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();
//再画一个三角鼻子
context.beginPath();
context.moveTo(250,250);//画布中指点一个点,不创建线条
context.lineTo(240,260);//添加一个新点,然后创建从该点到画布中最后指定点的线条(该方法并不会创建线条)
context.lineTo(260,260);//添加一个新点,然后创建从该点到画布中最后指定点的线条(该方法并不会创建线条)
context.closePath();//末点回到起点
context.stroke();
//再画一个嘴巴
context.beginPath();
context.arc(250,270,15,0,Math.PI,false);
context.stroke();
这么一看,canvas还是很好玩的哦
版权声明
本文为[孤身不觉晚]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_40043424/article/details/103633512
边栏推荐
- Mysql8 installation
- 软件测试周刊(第68期):解决棘手问题的最上乘方法是:静观其变,顺水推舟。
- 【蓝桥杯】4月17日省赛刷题训练(前3道题)
- 将新增和编辑的数据同步更新到列表
- 22. Bracket generation
- pyqt5 将opencv图片存入内置SQLlite数据库,并查询
- 进程虚拟地址空间区域划分
- Customize classloader and implement hot deployment - use loadclass
- Record a website for querying compatibility, string Replaceall() compatibility error
- Kernel error: no rule to make target 'Debian / canonical certs pem‘, needed by ‘certs/x509_ certificate_ list‘
猜你喜欢
Free and open source agricultural Internet of things cloud platform (version: 3.0.1)
内核错误: No rule to make target ‘debian/canonical-certs.pem‘, needed by ‘certs/x509_certificate_list‘
[51 single chip microcomputer traffic light simulation]
将新增和编辑的数据同步更新到列表
如何实现点击一下物体播放一次动画
AUTOSAR from introduction to mastery lecture 100 (84) - Summary of UDS time parameters
V-model binding value in El select, data echo only displays value, not label
MySQL —— 16、索引的数据结构
8086 of x86 architecture
SSM framework series - annotation development day2-2
随机推荐
Redis deployment of cloud native kubesphere
The accuracy and speed are perfectly balanced, and the latest image segmentation SOTA model is released!!!
Huawei cloud MVP email
(1) Openjuterpyrab comparison scheme
About the 'enum' enumeration type and structure.
Go language mapping operation
将opencv 图片转换为字节的方式
pyqt5 将opencv图片存入内置SQLlite数据库,并查询
内核错误: No rule to make target ‘debian/canonical-certs.pem‘, needed by ‘certs/x509_certificate_list‘
AUTOSAR from introduction to mastery lecture 100 (84) - Summary of UDS time parameters
If you were a golang interviewer, what questions would you ask?
[untitled] make a 0-99 counter, P1 7 connected to key, P2 connected to nixie tube section, common anode nixie tube, P3 0,P3. 1. Connect the nixie tube bit code. Each time you press the key, the nixie
拥抱机器视觉新蓝海,冀为好望开启数字经济发展新“冀”遇
Packet capturing and sorting -- TCP protocol [8]
21 days learning mongodb notes
5 free audio material websites, recommended collection
decast id.var measure.var数据拆分与合并
JDBC connection pool
Deploying MySQL in cloud native kubesphere
Learning materials