当前位置:网站首页>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
边栏推荐
- Van uploader upload picture implementation process, using native input to upload pictures
- SSM framework series - JUnit unit test optimization day2-3
- MySQL -- 16. Data structure of index
- 如何实现点击一下物体播放一次动画
- Important knowledge of network layer (interview, reexamination, term end)
- Embrace the new blue ocean of machine vision and hope to open a new "Ji" encounter for the development of digital economy
- Record some NPM related problems (messy records)
- Golang implements MD5, sha256 and bcrypt encryption
- nodeJs + websocket 循环小案例
- Teach you to quickly develop a werewolf killing wechat applet (with source code)
猜你喜欢
Use compressorjs to compress pictures, optimize functions, and compress pictures in all formats
CGC: contractual graph clustering for community detection and tracking
Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误
V-model binding value in El select, data echo only displays value, not label
Summary of JVM knowledge points - continuously updated
SSM framework series - JUnit unit test optimization day2-3
CVPR 2022&NTIRE 2022|首个用于高光谱图像重建的 Transformer
拥抱机器视觉新蓝海,冀为好望开启数字经济发展新“冀”遇
31. Next arrangement
22. Bracket generation
随机推荐
Connect orcale
Go language array operation
About the 'enum' enumeration type and structure.
Go language: passing slices between functions
Remote access to raspberry pie at home (Part 1)
Teach you to quickly develop a werewolf killing wechat applet (with source code)
The El table horizontal scroll bar is fixed at the bottom of the visual window
mysql8安装
AUTOSAR from introduction to mastery 100 lectures (86) - 2F of UDS service foundation
Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误
Go iris framework implements multi service Demo: start (listen to port 8084) service 2 through the interface in service 1 (listen to port 8083)
Pytorch: a pit about the implementation of gradreverselayer
mui 关闭其他页面,只保留首页面
Unable to create servlet under SRC subfile of idea
Important knowledge of network layer (interview, reexamination, term end)
AUTOSAR from introduction to mastery 100 lectures (81) - FIM of AUTOSAR Foundation
Start mqbroker CMD failure resolution
Go language slicing operation
Community version Alibaba MQ ordinary message sending subscription demo
Get the punch in record of nailing attendance machine