当前位置:网站首页>初鉴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
边栏推荐
- 7_Addmodule和基因加和法add 得到的细胞类型打分在空间上空转对比
- Design and manufacture of 51 single chip microcomputer solar charging treasure with low voltage alarm (complete code data)
- mysql支持ip访问
- JMeter operation redis
- Free and open source intelligent charging pile SaaS cloud platform of Internet of things
- Wonderful review | the sixth issue of "source" - open source economy and industrial investment
- 【蓝桥杯】4月17日省赛刷题训练(前3道题)
- Pytorch: a pit about the implementation of gradreverselayer
- (个人)最近项目开发后存在的系统漏洞整理
- Sort out several uses of network IP agent
猜你喜欢
Introduction to servlet listener & filter
No idle servers? Import OVF image to quickly experience smartx super fusion community version
Important knowledge of network layer (interview, reexamination, term end)
PC starts multiple wechat at one time
Free and open source charging pile Internet of things cloud platform
[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
jmeter操作redis
Van uploader upload picture implementation process, using native input to upload pictures
Install nngraph
Melt reshape decast long data short data length conversion data cleaning row column conversion
随机推荐
Introduction to servlet listener & filter
There is no need to crack the markdown editing tool typora
【蓝桥杯】4月17日省赛刷题训练(前3道题)
Learning materials
JDBC connection pool
JMeter operation redis
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
Servlet监听器&过滤器介绍
教你快速开发一个 狼人杀微信小程序(附源码)
Wonderful review | the sixth issue of "source" - open source economy and industrial investment
Get the punch in record of nailing attendance machine
No idle servers? Import OVF image to quickly experience smartx super fusion community version
31. 下一个排列
STD:: shared of smart pointer_ ptr、std::unique_ ptr
进程虚拟地址空间区域划分
Golang implements a five insurance and one gold calculator with web interface
async void 导致程序崩溃
4. DRF permission & access frequency & filtering & sorting
Connect orcale
CVPR 2022&NTIRE 2022|首个用于高光谱图像重建的 Transformer